-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix stuck predictive back platform channel calls #133368
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
Fix stuck predictive back platform channel calls #133368
Conversation
chunhtai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some nit picks
| _updateRouting(); | ||
| _locale = _resolveLocales(WidgetsBinding.instance.platformDispatcher.locales, widget.supportedLocales); | ||
| WidgetsBinding.instance.addObserver(this); | ||
| if (WidgetsBinding.instance.lifecycleState != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this check needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I'll change the variable to non-nullable and keep this check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I removed the check and kept it non-nullable, as you suggested. Otherwise there's a chance it could still be uninitialized.
| tearDown(() { | ||
| TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger | ||
| .setMockMethodCallHandler(SystemChannels.platform, null); | ||
| SystemNavigator.setFrameworkHandlesBack(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add comment when setting it to true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your comment makes me realize that this setting/resetting of this isn't necessary anymore. It used to be tracked in a static bool that would keep state between tests, but now it's not. I'll remove it here and elsewhere.
| if (WidgetsBinding.instance.lifecycleState != null) { | ||
| _appLifecycleState = WidgetsBinding.instance.lifecycleState; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This initialization is given in the example in the docs for WidgetsBindingObserver. I simply missed it in my last PR where I relanded predictive back to fix a similar test. I confirmed that this variable was incorrectly null for awhile in the failing tests, and after this change it gets set correctly.
However, the test continued to flake occasionally after this change, hence my other change above.
| switch(_appLifecycleState) { | ||
| case null: | ||
| case AppLifecycleState.detached: | ||
| case AppLifecycleState.inactive: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I then observed in the failing tests that the problematic calls were only made when the lifecycle was inactive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be handle on the engine side? it seems hard for the caller of SystemNavigator.setFrameworkHandlesBack to know this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my experimentation, the failure happens even if the engine doesn't handle the call at all. I've been super confused about how those tests are set up that this kind of timeout error is even possible. I would definitely be up for revisiting this code if someone finds a better way to avoid the failure.
…ys initialized, especially in tests
…state so it's not null
flutter/flutter@cd3aeef...ec387a4 2023-08-28 [email protected] Revert "ShortcutManager should dispatch creation in constructor." (flutter/flutter#133472) 2023-08-28 [email protected] Roll Flutter Engine from 9ab2603db24f to 91522a188bda (2 revisions) (flutter/flutter#133462) 2023-08-28 [email protected] FocusNode and FocusManager should dispatch creation in constructor. (flutter/flutter#133352) 2023-08-28 [email protected] ShortcutManager should dispatch creation in constructor. (flutter/flutter#133356) 2023-08-28 [email protected] Fix stuck predictive back platform channel calls (flutter/flutter#133368) 2023-08-28 [email protected] added option to change color of heading row(flutter#132428) (flutter/flutter#132728) 2023-08-28 [email protected] PlatformRouteInformationProvider should dispatch creation in constructor. (flutter/flutter#133353) 2023-08-28 [email protected] Roll Flutter Engine from 4924cf453398 to 9ab2603db24f (1 revision) (flutter/flutter#133449) 2023-08-28 [email protected] Roll Flutter Engine from d89824ab018f to 4924cf453398 (1 revision) (flutter/flutter#133447) 2023-08-28 [email protected] Roll Flutter Engine from b26e2da130ab to d89824ab018f (2 revisions) (flutter/flutter#133444) 2023-08-28 [email protected] Roll Flutter Engine from 78c26aeff3ee to b26e2da130ab (2 revisions) (flutter/flutter#133432) 2023-08-28 [email protected] Roll Flutter Engine from f8a171aa173f to 78c26aeff3ee (1 revision) (flutter/flutter#133428) 2023-08-28 [email protected] Roll Flutter Engine from 0593c0455fd6 to f8a171aa173f (1 revision) (flutter/flutter#133425) 2023-08-27 [email protected] Roll Flutter Engine from fc592728a7d0 to 0593c0455fd6 (4 revisions) (flutter/flutter#133419) 2023-08-27 [email protected] Roll Flutter Engine from b4e2758d6d43 to fc592728a7d0 (1 revision) (flutter/flutter#133410) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sometimes, platform channel calls to setFrameworkHandlesBack, were getting stuck when made when the app was shutting down. This was uncovered by Google tests that were flaking. This PR avoids making those calls and fixes the tests.
b/296900781