This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] implements a retry mechanism for dart:ui/Image.toByteData. #46840
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dc8231f
[Impeller] implements a retry mechanism for dart:ui/Image.toByteData.
gaaclarke de67844
removed the app_state_notifier, opting for observers on the sync switch
gaaclarke ecff455
fixed the existing test
gaaclarke de82a23
added test for retrying
gaaclarke 33f2ae6
factored out shared code
gaaclarke 4d6722c
quick cleanup
gaaclarke 0edb946
tidy
gaaclarke cd38f20
Added comments
gaaclarke 56298e9
updated docstring
gaaclarke 551f6ee
more docstrings
gaaclarke 3cd40b3
fixed platform tests to have a syncswitch
gaaclarke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,14 @@ class Context { | |
| kVulkan, | ||
| }; | ||
|
|
||
| /// The maximum number of tasks that should ever be stored for | ||
| /// `StoreTaskForGPU`. | ||
| /// | ||
| /// This number was arbitrarily chosen. The idea is that this is a somewhat | ||
| /// rare situation where tasks happen to get executed in that tiny amount of | ||
| /// time while an app is being backgrounded but still executing. | ||
| static constexpr int32_t kMaxTasksAwaitingGPU = 10; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh by the way. I'm open to increasing this. I just pulled this number out of nowhere but I knew I didn't want it to be completely unbounded.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would leave a note that this was arbitrarily chosen so we're not afraid to increase it in the future.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
|
|
||
| //---------------------------------------------------------------------------- | ||
| /// @brief Destroys an Impeller context. | ||
| /// | ||
|
|
@@ -176,6 +184,19 @@ class Context { | |
|
|
||
| CaptureContext capture; | ||
|
|
||
| /// Stores a task on the `ContextMTL` that is awaiting access for the GPU. | ||
| /// | ||
| /// The task will be executed in the event that the GPU access has changed to | ||
| /// being available or that the task has been canceled. The task should | ||
| /// operate with the `SyncSwitch` to make sure the GPU is accessible. | ||
| /// | ||
| /// Threadsafe. | ||
| /// | ||
| /// `task` will be executed on the platform thread. | ||
| virtual void StoreTaskForGPU(std::function<void()> task) { | ||
| FML_CHECK(false && "not supported in this context"); | ||
| } | ||
|
|
||
| protected: | ||
| Context(); | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a maximum limit of tasks? If we do have a limit, do we need a mechanism to drop them gracefully?
For example, if there is a Future pending from toByteData, I'd think that dropping the task should cause an error to be thrown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EncodeImageFailsWithoutGPUImpellertests this, it's handled gracefully since you have to check for the GPU in the callback and we never retry more than once. Getting dropped is just like the behavior we had before we implemented the retry.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, so when we exceed the size we execute the task, and then the task sees the GPU is still unavailable and errors? makes sense. I would document that a bit.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added that info to the Context::StoreTaskForGPU docstring.