Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@hellohuanlin
Copy link
Contributor

@hellohuanlin hellohuanlin commented Oct 18, 2024

This PR force reset forwarding recognizer state when it's stuck at failed state, by recreating the recognizer (we are not able to reset the state back to possible - it has to be reset by UIKit).

This is a tricky one since pencil and finger triggers exactly the same callbacks. It turns out that when pencil is involved after finger interaction, the platform view's "forwarding" gesture recognizer is stuck at failed state. This seems to be an iOS bug, because according to the API doc, it should be reset back to "possible" state:

No action message is sent and the gesture recognizer is reset to UIGestureRecognizerStatePossible.

However, when iPad pencil is involved, the state is not reset. I tried to KVO the state property, and wasn't able to capture the change. This means the state change very likely happened internally within the recognizer via the backing ivar of the state property.

Fixes flutter/flutter#136244

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@hellohuanlin
Copy link
Contributor Author

Tested the demo app from github issue and confirmed it's working. I will do more testing before landing it.

@hellohuanlin hellohuanlin force-pushed the pv_ipad_pencil_force_reset_recognizer branch from 5076c8e to 97c628b Compare October 18, 2024 19:26
@hellohuanlin hellohuanlin force-pushed the pv_ipad_pencil_force_reset_recognizer branch from 97c628b to 40e6eaa Compare October 18, 2024 19:33
@hellohuanlin hellohuanlin requested a review from jmagman October 18, 2024 19:34
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if change would impact it, but can you confirm the totally-not-running-anywhere iPad gesture tests still pass?
https://github.com/flutter/engine/blob/4e6405e2a89fa8fda2c0e7017ddcd8b39d7b3052/testing/scenario_app/ios/Scenarios/ScenariosUITests/iPadGestureTests.m

return self;
}

- (ForwardingGestureRecognizer*)recreateRecognizerWithTarget:(id)target {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible for ForwardingGestureRecognizer to instead implement NSCopying?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked to @hellohuanlin, this isn't feasible because of the move which makes the old recognizer unusable.


- (void)forceResetForwardingGestureRecognizerState {
// When iPad pencil is involved in a finger touch gesture, the gesture is not reset to "possible"
// state, which causes subsequent touches to be blocked. As a workaround, we force reset the state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and is stuck on "failed"

@hellohuanlin
Copy link
Contributor Author

Verified both google map and web view plugin example apps still work as expected.

@polina-c
Copy link
Contributor

@tdevaux confirmed this fixes the issue

@hellohuanlin
Copy link
Contributor Author

I don't know if change would impact it, but can you confirm the totally-not-running-anywhere iPad gesture tests still pass?
https://github.com/flutter/engine/blob/4e6405e2a89fa8fda2c0e7017ddcd8b39d7b3052/testing/scenario_app/ios/Scenarios/ScenariosUITests/iPadGestureTests.m

I got all of them failed with main branch on simulator. Let me try physical devices.

@jmagman
Copy link
Member

jmagman commented Oct 23, 2024

I got all of them failed with main branch on simulator. Let me try physical devices.

Don't worry about it, we can investigate later and get them passing and running somewhere.
Let's merge this! 🙂

@hellohuanlin
Copy link
Contributor Author

I was able to run on device and got the same failure as simulator. Filed flutter/flutter#157454

@hellohuanlin hellohuanlin added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 23, 2024
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 23, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 23, 2024

auto label is removed for flutter/engine/55958, due to - The status or check suite Mac mac_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label.

@jmagman jmagman added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 23, 2024
@auto-submit auto-submit bot merged commit 489aac4 into flutter:main Oct 23, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 23, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Oct 24, 2024
flutter/engine@73c54fa...5d7caf7

2024-10-23 34871572+gmackall@users.noreply.github.com Delete v1 android engine embedding (flutter/engine#52022)
2024-10-23 41930132+hellohuanlin@users.noreply.github.com [ios][platform_view]force reset forwarding recognizer state when its stuck (flutter/engine#55958)
2024-10-23 jason-simmons@users.noreply.github.com Allow running the YAPF formatter using Python version 3.11 (flutter/engine#56062)
2024-10-23 jonahwilliams@google.com [Impeller] optimize clip rects by checking if integral coverage is sufficient. (flutter/engine#56041)
2024-10-23 a-siva@users.noreply.github.com Switch the web compilation step to use an AOT snapshot (flutter/engine#56040)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC codefu@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
M97Chahboun pushed a commit to M97Chahboun/flutter that referenced this pull request Oct 30, 2024
…7478)

flutter/engine@73c54fa...5d7caf7

2024-10-23 34871572+gmackall@users.noreply.github.com Delete v1 android engine embedding (flutter/engine#52022)
2024-10-23 41930132+hellohuanlin@users.noreply.github.com [ios][platform_view]force reset forwarding recognizer state when its stuck (flutter/engine#55958)
2024-10-23 jason-simmons@users.noreply.github.com Allow running the YAPF formatter using Python version 3.11 (flutter/engine#56062)
2024-10-23 jonahwilliams@google.com [Impeller] optimize clip rects by checking if integral coverage is sufficient. (flutter/engine#56041)
2024-10-23 a-siva@users.noreply.github.com Switch the web compilation step to use an AOT snapshot (flutter/engine#56040)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC codefu@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
nick9822 pushed a commit to nick9822/flutter that referenced this pull request Dec 18, 2024
…stuck (flutter/engine#55958)

This PR force reset forwarding recognizer state when it's stuck at failed state, by recreating the recognizer (we are not able to reset the state back to possible - it has to be reset by UIKit). 

This is a tricky one since pencil and finger triggers exactly the same callbacks. It turns out that when pencil is involved after finger interaction, the platform view's "forwarding" gesture recognizer is stuck at failed state. This seems to be an iOS bug, because according to [the API doc](https://developer.apple.com/documentation/uikit/uigesturerecognizerstate/uigesturerecognizerstatefailed?language=objc), it should be reset back to "possible" state:

> No action message is sent and the gesture recognizer is reset to [UIGestureRecognizerStatePossible](https://developer.apple.com/documentation/uikit/uigesturerecognizerstate/uigesturerecognizerstatepossible?language=objc).

However, when iPad pencil is involved, the state is not reset. I tried to KVO the state property, and wasn't able to capture the change. This means the state change very likely happened internally within the recognizer via the backing ivar of the state property.

Fixes flutter#136244

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PlatformView][iOS] Touch gesture on InteractiveViewer stops working if you touch your finger first and then touch with Apple Pencil on iPad

3 participants