[CP-stable]Started querying the app state for the gpu disabled sync switch (#172121)

This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request)
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

### Issue Link:
What is the link to the issue this cherry-pick is addressing?

https://github.com/flutter/flutter/issues/166668

### Changelog Description:
Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples

For Flutter users on iOS, this fixes a case where images can fail to load and present themselves as magenta boxes when the Flutter app is created in the background state (example: responding to notifications).

### Impact Description:
What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch)

Images present themselves as magenta boxes.

### Workaround:
Is there a workaround for this issue?

No.

### Risk:
What is the risk level of this cherry-pick?

### Test Coverage:
Are you confident that your fix is well-tested by automated tests?

\* Caveat, the typical workflow is well tested.  The problematic workflow that this fixes is not.

### Validation Steps:
What are the steps to validate that this fix works?

The reproduction steps are quite involved and require manipulation of the operating system.  Slava was able to reproduce the problem and verify manually that this change fixes it.
This commit is contained in:
flutteractionsbot 2025-07-15 15:39:12 -07:00 committed by GitHub
parent 47c02c8b8f
commit 39d6d6e699
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -852,7 +852,11 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS
); );
// Disable GPU if the app or scene is running in the background. // Disable GPU if the app or scene is running in the background.
self.isGpuDisabled = self.viewController.stateIsBackground; self.isGpuDisabled = self.viewController
? self.viewController.stateIsBackground
: FlutterSharedApplication.application &&
FlutterSharedApplication.application.applicationState ==
UIApplicationStateBackground;
// Create the shell. This is a blocking operation. // Create the shell. This is a blocking operation.
std::unique_ptr<flutter::Shell> shell = flutter::Shell::Create( std::unique_ptr<flutter::Shell> shell = flutter::Shell::Create(