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

FlutterFragment forced to visiable when Activity resumed #105203

Closed
zxjzerg opened this issue Jun 2, 2022 · 9 comments · Fixed by flutter/engine#34601
Closed

FlutterFragment forced to visiable when Activity resumed #105203

zxjzerg opened this issue Jun 2, 2022 · 9 comments · Fixed by flutter/engine#34601
Assignees
Labels
a: existing-apps Integration with existing apps via the add-to-app flow c: regression It was better in the past than it is now engine flutter/engine repository. See also e: labels. found in release: 3.0 Found to occur in 3.0 found in release: 3.1 Found to occur in 3.1 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-android Android applications specifically waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Comments

@zxjzerg
Copy link

zxjzerg commented Jun 2, 2022

I use FlutterFragment as a Tab in my application. After I upgrade Flutter to 3.0.0 I meet an issue that if the FlutterFragment is set to hidden, when the Activity resumes, the FlutterFragment will become visiable.
This not happen when I use Flutter 2.10.5.

Project for reproducing this issue

I read the souce code of FlutterActivityAndFragmentDelegat in Flutter 3.0.0 and find out when the Fragment's onStart is called, it set the FlutterView to visiable. This changes are introduced by #30897.

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);
}
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.1, on macOS 11.6.5 20G527 darwin-x64, locale
    en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version
    33.0.0-rc2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.67.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
@zxjzerg
Copy link
Author

zxjzerg commented Jun 2, 2022

@ColdPaleLight pls check this

@exaby73 exaby73 added the in triage Presently being triaged by the triage team label Jun 2, 2022
@exaby73
Copy link
Member

exaby73 commented Jun 2, 2022

I can replicate this behavior. Though one thing to note, I have noticed that when I tap on "Recent apps" button, then immediately go back to the app, the view is still invisible. It's when I tap on the "Home" button, then resume the app is when this bug occurs.

flutter doctor -v (Stable)
[✓] Flutter (Channel stable, 3.0.1, on macOS 12.4 21F79 darwin-arm, locale en-US)
    • Flutter version 3.0.1 at /Users/nabeelparkar/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision fb57da5f94 (12 days ago), 2022-05-19 15:50:29 -0700
    • Engine revision caaafc5604
    • Dart version 2.17.1
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/nabeelparkar/Library/Android/sdk/
    • Platform android-32, build-tools 32.1.0-rc1
    • ANDROID_SDK_ROOT = /Users/nabeelparkar/Library/Android/sdk/
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /Applications/Brave Browser.app/Contents/MacOS/Brave Browser

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.1.1)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 67.1.4
    • Dart plugin version 221.5591.58

[✓] VS Code (version 1.67.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.4 21F79 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Brave Browser 102.1.39.111

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
flutter doctor -v (Master)
[✓] Flutter (Channel master, 3.1.0-0.0.pre.1035, on macOS 12.4 21F79 darwin-arm, locale en-US)
    • Flutter version 3.1.0-0.0.pre.1035 at /Users/nabeelparkar/fvm/versions/master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 3d62732d60 (2 hours ago), 2022-06-01 00:14:14 -0400
    • Engine revision 0d1057ef7b
    • Dart version 2.18.0 (build 2.18.0-157.0.dev)
    • DevTools version 2.13.1

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/nabeelparkar/Library/Android/sdk/
    • Platform android-32, build-tools 32.1.0-rc1
    • ANDROID_SDK_ROOT = /Users/nabeelparkar/Library/Android/sdk/
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /Applications/Brave Browser.app/Contents/MacOS/Brave Browser

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.1.1)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 67.1.4
    • Dart plugin version 221.5591.58

[✓] VS Code (version 1.67.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.4 21F79 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Brave Browser 102.1.39.111

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

@exaby73 exaby73 added platform-android Android applications specifically a: existing-apps Integration with existing apps via the add-to-app flow found in release: 3.0 Found to occur in 3.0 found in release: 3.1 Found to occur in 3.1 and removed in triage Presently being triaged by the triage team labels Jun 2, 2022
@ColdPaleLight ColdPaleLight self-assigned this Jun 2, 2022
@ColdPaleLight
Copy link
Member

Closing it var linked PR

@exaby73 exaby73 added the r: fixed Issue is closed as already fixed in a newer version label Jul 12, 2022
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 26, 2022
@ColdPaleLight ColdPaleLight reopened this Aug 24, 2022
@ColdPaleLight
Copy link
Member

@danagbemava-nc danagbemava-nc removed the r: fixed Issue is closed as already fixed in a newer version label Aug 24, 2022
@exaby73 exaby73 added has reproducible steps The issue has been confirmed reproducible and is ready to work on engine flutter/engine repository. See also e: labels. labels Aug 24, 2022
@flutter flutter unlocked this conversation Aug 30, 2022
@Nayuta403
Copy link
Member

There are two issues to be addressed here:

  1. flutterView.getVisibility() sometimes it's not accurate, use flutterView.isShown() is more accurate.

For example, nesting a FlutterFragment in FragmentA and setting FragmentA to View.GONE , it does not work for FlutterFragment. flutterView.getVisibility() is still VISIBLE.

https://github.com/flutter/engine/blob/51d14176b6dad39ca707f7916cf528c2aacd6652/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java#L605

image

This problem can be reproduced in this project code :d6dad6cbaabacc68f43406a50fc216c9fa752ccc

  1. flutterView.setVisibility(View.GONE) does not work for FlutterSurfaceView. We need to set Visibility extra to FlutterSurfaceView.

After calling flutterView.setVisibility(View.GONE), switching from the background to the foreground flutterview will still be displayed.For FlutterSurfaceView, setting View.GONE to the current FlutterView will not take effect since it is not in the view tree.

image

This problem can be reproduced in this project code :main

This problem was solved when I changed it to texture

For these two questions, I will finish PR later

@stuartmorgan stuartmorgan added P2 Important issues not at the top of the work list c: regression It was better in the past than it is now labels Aug 30, 2022
@gmackall
Copy link
Member

@zxjzerg It looks like there was a PR marked as fixing this issue that was merged in September. Can you confirm the fix?

@gmackall gmackall added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 15, 2023
@github-actions
Copy link

github-actions bot commented Jul 6, 2023

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.

@github-actions github-actions bot closed this as completed Jul 6, 2023
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: existing-apps Integration with existing apps via the add-to-app flow c: regression It was better in the past than it is now engine flutter/engine repository. See also e: labels. found in release: 3.0 Found to occur in 3.0 found in release: 3.1 Found to occur in 3.1 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-android Android applications specifically waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
None yet
7 participants