-
Notifications
You must be signed in to change notification settings - Fork 6k
Change visibility of FlutterView when onStop/onStart #30897
Changes from all commits
515e735
e144a6b
b44cfce
644f990
930bba2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,7 +74,7 @@ | |
| // to this FlutterActivityAndFragmentDelegate. | ||
| @NonNull private Host host; | ||
| @Nullable private FlutterEngine flutterEngine; | ||
| @Nullable private FlutterView flutterView; | ||
| @VisibleForTesting @Nullable FlutterView flutterView; | ||
| @Nullable private PlatformPlugin platformPlugin; | ||
| @VisibleForTesting @Nullable OnPreDrawListener activePreDrawListener; | ||
| private boolean isFlutterEngineFromHost; | ||
|
|
@@ -388,6 +388,12 @@ void onStart() { | |
| Log.v(TAG, "onStart()"); | ||
| ensureAlive(); | ||
| doInitialFlutterViewRun(); | ||
| // This is a workaround for a bug on some OnePlus phones. The visibility of the application | ||
| // window is still true after locking the screen on some OnePlus phones, and shows a black | ||
| // screen when unlocked. We can work around this by changing the visibility of FlutterView in | ||
| // onStart and onStop. | ||
| // See https://github.com/flutter/flutter/issues/93276 | ||
| flutterView.setVisibility(View.VISIBLE); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meet an issue because of this edit. My use case is I use FlutterFragment as a tab in Activity, when user switched to other tabs, I will hide the FlutterFragment. After this commit, every time Activity resumed, the flutterView will be foreced to visible, even the FlutterFragment is set to hide.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please file a new issue with minimum reproducible code, thank you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
this merge doest fix the issue; this is my code to reproduce, |
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -574,6 +580,12 @@ void onStop() { | |
| Log.v(TAG, "onStop()"); | ||
| ensureAlive(); | ||
| flutterEngine.getLifecycleChannel().appIsPaused(); | ||
| // This is a workaround for a bug on some OnePlus phones. The visibility of the application | ||
| // window is still true after locking the screen on some OnePlus phones, and shows a black | ||
| // screen when unlocked. We can work around this by changing the visibility of FlutterView in | ||
| // onStart and onStop. | ||
| // See https://github.com/flutter/flutter/issues/93276 | ||
| flutterView.setVisibility(View.GONE); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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.
nit: please add some comment(s) here and below about why we're doing this, with a link to the bug
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.
Done