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

Android Embedding PR28: Report app is active to Flutter in FlutterFragment.onResume() instead of onPostResume() forwarded from Activity. #8536

Conversation

matthew-carroll
Copy link
Contributor

Android Embedding PR28: Report app is active to Flutter in FlutterFragment.onResume() instead of onPostResume() forwarded from Activity.

@mjohnsullivan was testing the latest engine with Flutter as a Fragment. The Flutter Fragment worked on initial presentation, but switching to an Android tab and then switching back to the Flutter tab, the Flutter UI would not display itself any more.

Based on some log tracing I believe the root cause is tied to when we are notifying the Flutter engine that the app is active. The host platform is responsible for telling the engine when the app is "active", "paused" or "inactive". The "active" message was being sent in response to the host Activity telling the FlutterFragment that onPostResume() had executed.

The problem with using onPostResume() is that Fragments do not naturally receive this message. We have to forward it from the Activity. But Fragments also come and go within an Activity's lifecycle, which means a FlutterFragment might go from "active" to "inactive" to "active" again without ever receiving additional onPostResume() calls. As a result, the FlutterFragment would be recreated, it would setup its view hierarchy, it would resume, but it would never tell the engine that we're "active" because the FlutterFragment never got a repeat invocation of onPostResume().

The solution I've chosen is to simply report that the app is "active" in the Fragment's onResume(). I'm not sure why this was ever done in onPostResume() and I'm not immediately aware of anything that might stop working as a result of doing this in onResume() instead.

…gment.onResume() instead of onPostResume() forwarded from Activity.
Copy link
Contributor

@mklim mklim left a comment

Choose a reason for hiding this comment

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

LGTM

@matthew-carroll matthew-carroll merged commit 892591d into flutter:master Apr 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 11, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 11, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 11, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 11, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 11, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 11, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 11, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 11, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 11, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 11, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 11, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 12, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 12, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 12, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Apr 12, 2019
flutter/engine@72986c3...f804c29

git log 72986c3..f804c29 --no-merges --oneline
f804c29 Roll src/third_party/skia 3b60397fd35d..f74fff660084 (3 commits) (flutter/engine#8556)
1b448e5 Roll Dart 15b11b018364ce032eae50d78fc8a52b541e2bce...a8f3a5dae6203d1064726a5953cf06a7d484249c (flutter/engine#8555)
99259ae Roll src/third_party/skia 36477b49c2ef..3b60397fd35d (6 commits) (flutter/engine#8554)
f37220d Roll src/third_party/skia c33e6dcc700b..36477b49c2ef (8 commits) (flutter/engine#8552)
d84d204 Android Embedding PR30: Make FlutterView focusable so that the keyboard can interact with it. (flutter/engine#8551)
a344015 [fuchsia] Add flutter:: to scene_host.cc (flutter/engine#8549)
711d843 Roll src/third_party/skia 76e626d9bb55..c33e6dcc700b (4 commits) (flutter/engine#8547)
82e6d68 Eliminate unused write to local (flutter/engine#8541)
f53e477 Correct nullability for FlutterStandardReader (flutter/engine#8537)
c00364a [font_collection] Add missing semicolon (flutter/engine#8546)
ae4df6f Revert "Change Rect internal representation from Float32List to Float64List (#8524)" (flutter/engine#8545)
ffdddb0 Roll src/third_party/skia 6d60534e95d8..76e626d9bb55 (1 commits) (flutter/engine#8544)
5ac728e Roll src/third_party/skia 4d657d5e894a..6d60534e95d8 (3 commits) (flutter/engine#8543)
ee462ff Roll src/third_party/skia 99d792276740..4d657d5e894a (1 commits) (flutter/engine#8542)
18816c5 Roll src/third_party/skia 42280f8961fa..99d792276740 (8 commits) (flutter/engine#8539)
892591d Android Embedding PR28: Report app is active to Flutter in FlutterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
330c6c1 Use code cache dir for engine cache on API >= 21 (#14704). (flutter/engine#8534)
c10ae2b Add an option to build the GLFW shell on macOS (flutter/engine#8531)
29aa5fc Roll src/third_party/skia b5c685991faa..42280f8961fa (32 commits) (flutter/engine#8535)
0a2869e Added support for authentication codes for the VM service (flutter/engine#8527)
36d2135 Redo a fix for cull rect calculation on TransformLayers with a perspective transform (flutter/engine#8528)
0b36d3e Change Rect internal representation from Float32List to Float64List (flutter/engine#8524)
b1ae0cc Roll src/third_party/skia 10bf7020aa15..b5c685991faa (3 commits) (flutter/engine#8526)

The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff (jsimmons@google.com), and stop
the roller if necessary.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 13, 2019
…utterFragment.onResume() instead of onPostResume() forwarded from Activity. (flutter/engine#8536)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants