Skip to content

FlutterFragment forced to visiable when Activity resumed #105203

@zxjzerg

Description

@zxjzerg

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

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: existing-appsIntegration with existing apps via the add-to-app flowc: regressionIt was better in the past than it is nowengineflutter/engine related. See also e: labels.found in release: 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallywaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions