Repository navigation
Description
FlutterEngine.isGpuDisabled is a public read/write property, but a value assigned to it before the engine runs is silently clobbered before it ever reaches the shell.
-[FlutterEngine createShell:libraryURI:initialRoute:] samples the current lifecycle state by assigning to the property, immediately before constructing the shell:
flutter/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
Lines 931 to 936 in 0abb611
| // Disable GPU if the app or scene is running in the background. | |
| self.isGpuDisabled = self.viewController | |
| ? self.viewController.stateIsBackground | |
| : FlutterSharedApplication.application && | |
| FlutterSharedApplication.application.applicationState == | |
| UIApplicationStateBackground; |
The value is then passed to Shell::Create as is_gpu_disabled. Because the sampling is an unconditional assignment to a public property, it also destroys whatever the caller set beforehand. An embedder that does:
engine.isGpuDisabled = YES;
[engine run];silently gets the GPU enabled, with no warnings whatsoever.
The sampling itself is necessary and shouldn't be deleted. Lifecycle notifications only report transitions, so an engine created while the application or scene is already backgrounded never receives one and would otherwise come up believing the GPU is available.
The problem is more with where we do this work and the fact that it silently clobbers the state with no warning.
Why is this a problem for Embedder API migration?
FlutterEngineRun would naturally accept initial GPU availability as a project argument, if we add it. Passing that property straight through would resurrect exactly the stale value that createShell: currently goes out of its way clobber.
Activity
iOS: test GPU availability and task queue behaviour
iOS: test GPU availability and task queue behaviour (flutter#190836)
iOS: Stop discarding the GPU state set before an engine runs
iOS: Stop discarding the GPU state set before an engine runs
iOS: Stop discarding the GPU state set before an engine runs
iOS: Stop discarding the GPU state set before an engine runs
iOS: Don't discard GPU state set before an engine runs (flutter#191055)
github-actions commentedon Sep 1, 2026
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 -vand a minimal reproduction of the issue.