impeller: makes deferred display list images trash their display lists after they are realized#178259
Conversation
jason-simmons
left a comment
There was a problem hiding this comment.
One potential issue is that this may result in usages of toImageSync that are safe when using Impeller but consume excessive resources on platforms that are still using Skia. App developers will need to be aware of this as long as Skia remains in use.
I think that's fine because this isn't the only place this happens. Impeller was created with the intention to be a renderer with better performance for Flutter's use case. That means there are all sorts of usages that are supposed to be better on impeller than on skia. We don't want logical changes, but performance changes are expected. |
| } | ||
|
|
||
| void DlDeferredImageGPUImpeller::ImageWrapper::SnapshotDisplayList( | ||
| sk_sp<DisplayList> display_list, |
There was a problem hiding this comment.
Declare this parameter as a std::variant to indicate that this takes either a DisplayList or a LayerTree but not both.
| @@ -106,7 +111,8 @@ class DlDeferredImageGPUImpeller final : public DlImage { | |||
| // thread task spawned by this method. After being flattened into a display | |||
| // list, the image wrapper will be updated to hold this display list and the | |||
There was a problem hiding this comment.
Delete the part of this comment saying that the image wrapper will hold the display list.
| display_list = layer_tree->Flatten( | ||
| DlRect::MakeWH(wrapper->size_.width, wrapper->size_.height), | ||
| wrapper->texture_registry_); | ||
| texture_registry); |
There was a problem hiding this comment.
The texture_registry variable can be removed and snapshot_delegate->GetTextureRegistry() can be passed here
| namespace testing { | ||
| namespace { | ||
|
|
||
| void PostTaskSync(const fml::RefPtr<fml::TaskRunner>& task_runner, |
There was a problem hiding this comment.
Remove the local version of this function and use the one from #include "flutter/testing/post_task_sync.h"
| fml::TaskRunnerAffineWeakPtr<SnapshotDelegate> snapshot_delegate, | ||
| fml::RefPtr<fml::TaskRunner> raster_task_runner) | ||
| : size_(size), | ||
| display_list_(std::move(display_list)), |
There was a problem hiding this comment.
Remove the display_list parameter from the ImageWrapper constructor
std::variant removed posttasksync inlined variable removed arg update comment
| void SnapshotDisplayList( | ||
| std::variant<sk_sp<DisplayList>, std::unique_ptr<LayerTree>> content); |
There was a problem hiding this comment.
Looking at this now, we probably should have just overloaded the constructor. Oh well, that was fun.
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…lay lists after they are realized (flutter/flutter#178259)
…s after they are realized (flutter#178259) fixes flutter#138627 This stops ballooning recursive display_lists that can happen in animations. The display list actually can be larger than the image so keeping the display list around is no benefit. In rare cases this could make the memory size of backgrounded apps be larger but this keeps images made with toImageSync have the same semantics as toImage on impeller. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
…s after they are realized (flutter#178259) fixes flutter#138627 This stops ballooning recursive display_lists that can happen in animations. The display list actually can be larger than the image so keeping the display list around is no benefit. In rare cases this could make the memory size of backgrounded apps be larger but this keeps images made with toImageSync have the same semantics as toImage on impeller. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
…s after they are realized (flutter#178259) fixes flutter#138627 This stops ballooning recursive display_lists that can happen in animations. The display list actually can be larger than the image so keeping the display list around is no benefit. In rare cases this could make the memory size of backgrounded apps be larger but this keeps images made with toImageSync have the same semantics as toImage on impeller. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
…lay lists after they are realized (flutter/flutter#178259)
fixes #138627
This stops ballooning recursive display_lists that can happen in animations. The display list actually can be larger than the image so keeping the display list around is no benefit. In rare cases this could make the memory size of backgrounded apps be larger but this keeps images made with toImageSync have the same semantics as toImage on impeller.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.