From 39d6d6e699e51b2874210e14cddf1a22fb9524b2 Mon Sep 17 00:00:00 2001 From: flutteractionsbot <154381524+flutteractionsbot@users.noreply.github.com> Date: Tue, 15 Jul 2025 15:39:12 -0700 Subject: [PATCH] [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. --- .../platform/darwin/ios/framework/Source/FlutterEngine.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index c791cf2861..daae40eb5e 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -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. - 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. std::unique_ptr shell = flutter::Shell::Create(