Skip to content

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Jun 18, 2025

Includes:

Fix image decode errors on iOS that could occur if a push notification triggered image decoding while the app is backgrounded.

Jonah Williams added 2 commits June 18, 2025 15:44
…ling and log gpu errors. (flutter#169378)

Attempted fix for flutter#166668 .
Plan is to ask for testing once rolled into g3 since we weren't given a
repro.

Explaination: we can only submit command buffers to the metal command
queue when the device is in the foreground. push notifications
temporarily wake up the app and can trigger images to begin decoding.
This decoding can fail, possibly due to the app re-backgrounding. In
theory, the sync switch should prevent this from happening - but because
we don't actually block on the scheduling of the command buffer there is
technically a race that can happen.

Add the ability to block submission on scheduling for metal. note that
other graphics APIs do not have a distinction for commited vs scheduled
and so it no-ops for them.


See
https://developer.apple.com/documentation/metal/preparing-your-metal-app-to-run-in-the-background

> When UIKit calls your app delegate’s
[applicationDidEnterBackground(_:)](https://developer.apple.com/documentation/UIKit/UIApplicationDelegate/applicationDidEnterBackground(_:))
method, make sure Metal has scheduled all command buffers you’ve already
committed before your app returns control to the system. ... Finish
encoding commands to render the frame and commit the command buffer,
then call
[waitUntilScheduled()](https://developer.apple.com/documentation/metal/mtlcommandbuffer/waituntilscheduled()).
@flutter-dashboard
Copy link

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@github-actions github-actions bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Jun 18, 2025
@jonahwilliams jonahwilliams added the cp: stable cherry pick this pull request to stable release candidate branch label Jun 23, 2025
@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 23, 2025
@auto-submit auto-submit bot merged commit 82f2933 into flutter:flutter-3.32-candidate.0 Jun 23, 2025
165 checks passed
@maxbritto
Copy link

maxbritto commented Jun 26, 2025

This may also fix #159397
In my experience this bug was happening quite often if an app had 20+ (small) images displayed and the user was getting in and out of the app regularly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App cp: stable cherry pick this pull request to stable release candidate branch e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants