Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent HapticFeedback on iOS #25284

Open
AncientLust opened this issue Oct 15, 2024 · 2 comments
Open

Inconsistent HapticFeedback on iOS #25284

AncientLust opened this issue Oct 15, 2024 · 2 comments
Labels
platform/iOS 🍎 s/needs-attention Issue has more information and needs another look t/bug Something isn't working

Comments

@AncientLust
Copy link

AncientLust commented Oct 15, 2024

Description

The issue is with HapticFeedback.Default.Perform. On iOS it works or not depending on what code follows this line. Sometimes with some chance. For example:

  1. In this case haptic feedback works in 90% of the cases when button is pressed:
[RelayCommand]
private void Play()
{
    HapticFeedback.Default.Perform(HapticFeedbackType.Click);
    _currentState.Play();
}
  1. In this case haptic feedback works in 100% of the cases when button is pressed:
[RelayCommand]
private void Play()
{
    HapticFeedback.Default.Perform(HapticFeedbackType.Click);
    // _currentState.Play();
}

The situation getting worse when you try to use haptic feedback in a more complex situation, like this:

private async Task HandleIncorrectAnswer()
{
    await Task.Delay(100);
    HapticFeedback.Default.Perform(HapticFeedbackType.Click);
    await Task.Delay(100);
    HapticFeedback.Default.Perform(HapticFeedbackType.Click);
}

In this case it just can have zero vibrations, vibrate only once or vibrate twice as you expect.

Let us keep this bug report for a while just to see if people have the same issues with haptic feedback. Because googling of "MAUI inconsistent haptic feedback" returns nothing.

What I tried:

  1. Run HapticFeedback.Default.Perform from main thread via MainThread.BeginInvokeOnMainThread / InvokeOnMainThreadAsync.
  2. Run HapticFeedback.Default.Perform via "run and forget" using Task.Run().

Don't see this issue on Android. On iOS both Click and LongPress have this problematic behavior.

Steps to Reproduce

Wasn't able to reproduce in the clean MAUI project, since behaviour depends on the code which follows haptic feedback usage. Without it it works fine. I will update the bug report if I will find a way to reproduce it.

Link to public reproduction project repository

No response

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 17.6.1

Did you find any workaround?

So far the only workaround I found is to place await Task.Delay() afterwards with at least 100 ms to make the vibration stable.

Relevant log output

No response

@AncientLust AncientLust added the t/bug Something isn't working label Oct 15, 2024
@PureWeen PureWeen added the s/needs-repro Attach a solution or code which reproduces the issue label Oct 21, 2024
@AncientLust
Copy link
Author

Repro project: https://github.com/AncientLust/InconsistentHapticFeedback

I added two lines into community sample app which call haptic feedback right before speech recognition start:

async Task Listen(CancellationToken cancellationToken)
{
    CanStartListenExecute = false;
    
    HapticFeedback.Default.Perform(HapticFeedbackType.Click);
    
    ...
}
async Task StartListen(CancellationToken cancellationToken)
{
    CanListenExecute = false;
    CanStartListenExecute = false;
    CanStopListenExecute = true;

    HapticFeedback.Default.Perform(HapticFeedbackType.Click);

    ...
}

How to reproduce the issue:

  1. Run Sample app on iOS device.
  2. Open Essentials -> SpeechToText.
  3. Try to click on ListenAsync and StartListenAsync buttons. Haptic feedback supposed to happen on button click. But it works with about 2% chance.

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Oct 26, 2024
@bcaceiro
Copy link

I have also the same issue, haptic feedback works rarelly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/iOS 🍎 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants