Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Cleanup the IO thread GrContext #14265

Merged
merged 4 commits into from
Dec 11, 2019
Merged

Cleanup the IO thread GrContext #14265

merged 4 commits into from
Dec 11, 2019

Conversation

liyuqian
Copy link
Contributor

@liyuqian liyuqian commented Dec 9, 2019

Fixes flutter/flutter#19558

This is tested by the devicelab test fast_scroll_large_images__memory

@@ -39,6 +43,11 @@ void SkiaUnrefQueue::Drain() {
for (SkRefCnt* skia_object : skia_objects) {
skia_object->unref();
}

if (context_ != nullptr) {
TRACE_EVENT0("flutter", "SkiaUnrefQueue::Drain performDeferredCleanup");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to trace the duration of this?

Did you work out whatever issues were causing this to take 16ms+?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove that. I just figured out that our Drain task has already had a throttling of once every 3 seconds so a dozen milliseconds of cleanup is fine. The speed difference is due to the difference between the precompiled debug engine and my local debug engine (precompiled probably has opt while local one has unopt build). Switching to profile would eliminate the difference...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not concerned with removing it :) But this seems like a nice candidate for TRACE_DURATION rather than TRACE_EVENT0.

liyuqian added a commit to liyuqian/flutter that referenced this pull request Dec 9, 2019
The waiting time would give our cleanup more room to finish the job, and
thus to make our result more accurate.

See also flutter/engine#14265
Fixes flutter/flutter#19558

This is tested by the devicelab test fast_scroll_large_images__memory
Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit but otherwise LGTM.

@@ -39,6 +43,11 @@ void SkiaUnrefQueue::Drain() {
for (SkRefCnt* skia_object : skia_objects) {
skia_object->unref();
}

if (context_ != nullptr) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The unref queue drains all objects after drain_delay_ but the task is posted on every GPU object unref. So it is possible to for this method to not actually unref any objects because they were cleared on a previous unref. So its good to only perform deferred cleanup if skia_objects.size() > 0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we track SkImage objects in this queue? I thought this was only for GPU context objects?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. SkImages are GPU context related. We also track other objects that may themselves reference SkImages as well (like pictures).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Otherwise, the IOManager may be destructed before the Drain is called
and that could cause a crash.
@liyuqian
Copy link
Contributor Author

@chinmaygarde : please check the thread issue that I discussed with you earlier in d536937

@liyuqian liyuqian merged commit 212fbba into flutter:master Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2019
iskakaushik pushed a commit to iskakaushik/flutter that referenced this pull request Dec 12, 2019
flutter/engine@12bf95f...db60ebc

git log 12bf95f..db60ebc --first-parent --oneline
2019-12-11 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/mac-amd64 from h4iiT... to otkJA... (flutter/engine#14327)
2019-12-11 skia-flutter-autoroll@skia.org Roll src/third_party/dart bd008dd1e406..d9fa37e85d5c (1 commits) (flutter/engine#14325)
2019-12-11 skia-flutter-autoroll@skia.org Roll src/third_party/skia 5afc7b2af854..75799967be60 (2 commits) (flutter/engine#14324)
2019-12-11 skia-flutter-autoroll@skia.org Roll src/third_party/dart bcd18e67dcae..bd008dd1e406 (3 commits) (flutter/engine#14322)
2019-12-11 chinmaygarde@google.com Verify accounting for loop counts in Gif and WebP assets is consistent. (flutter/engine#14321)
2019-12-11 iska.kaushik@gmail.com [fuchsia] Do not Execute paint tasks when there is no vsync (flutter/engine#14298)
2019-12-11 skia-flutter-autoroll@skia.org Roll src/third_party/dart c74a8ec2c46e..bcd18e67dcae (9 commits) (flutter/engine#14317)
2019-12-11 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/linux-amd64 from nqJnP... to UdfLO... (flutter/engine#14316)
2019-12-11 skia-flutter-autoroll@skia.org Roll src/third_party/skia 732c49739fa5..5afc7b2af854 (16 commits) (flutter/engine#14315)
2019-12-11 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/mac-amd64 from 9C6UA... to h4iiT... (flutter/engine#14314)
2019-12-11 iska.kaushik@gmail.com [web] Update build_web_compilers to 2.7.1 (flutter/engine#14305)
2019-12-11 liyuqian@google.com Cleanup the IO thread GrContext (flutter/engine#14265)
2019-12-10 50856934+nturgut@users.noreply.github.com Fix for tab not working (flutter/engine#14165)
2019-12-10 jason-simmons@users.noreply.github.com [SkParagraph] Convert the height override flag in text styles (flutter/engine#14283)
2019-12-10 bkonyi@google.com Roll src/third_party/dart 02a8b015ad..98c13ba18f (5 commits) (flutter/engine#14280)
2019-12-10 tvolkert@users.noreply.github.com Remove specificity on Android and iOS (flutter/engine#14282)
2019-12-10 jason-simmons@users.noreply.github.com Create separate objects for isolate state and isolate group state (flutter/engine#14268)
2019-12-10 bkonyi@google.com Roll src/third_party/dart 8b8894648f..02a8b015ad (26 commits) (flutter/engine#14278)
2019-12-10 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/linux-amd64 from Zkpa_... to nqJnP... (flutter/engine#14274)
2019-12-10 skia-flutter-autoroll@skia.org Roll src/third_party/skia e56cc054dbae..ab26643258ad (3 commits) (flutter/engine#14273)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC kaushikiska@google.com on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
iskakaushik pushed a commit to flutter/flutter that referenced this pull request Dec 13, 2019
* 571c999 Roll src/third_party/skia e56cc054dbae..ab26643258ad (3 commits) (flutter/engine#14273)

* 140818a Roll fuchsia/sdk/core/linux-amd64 from Zkpa_... to nqJnP... (flutter/engine#14274)

* ed6830e Roll src/third_party/dart 8b8894648f..02a8b015ad (26 commits) (flutter/engine#14278)

* b7d4278 Create separate objects for isolate state and isolate group state (flutter/engine#14268)

* 57afd86 Remove specificity on Android and iOS (flutter/engine#14282)

* b7c947d Roll src/third_party/dart 02a8b015ad..98c13ba18f (5 commits) (flutter/engine#14280)

* 76d264e [SkParagraph] Convert the height override flag in text styles (flutter/engine#14283)

* deb8e57 Fix for tab not working (flutter/engine#14165)

* 212fbba Cleanup the IO thread GrContext (flutter/engine#14265)

* 3e55f64 [web] Update build_web_compilers to 2.7.1 (flutter/engine#14305)

* b6d4fd1 Roll fuchsia/sdk/core/mac-amd64 from 9C6UA... to h4iiT... (flutter/engine#14314)

* c0b1dc0 Roll src/third_party/skia 732c49739fa5..5afc7b2af854 (16 commits) (flutter/engine#14315)

* 5b5206e Roll fuchsia/sdk/core/linux-amd64 from nqJnP... to UdfLO... (flutter/engine#14316)

* 058b4bc Roll src/third_party/dart c74a8ec2c46e..bcd18e67dcae (9 commits) (flutter/engine#14317)

* 6430ecf [fuchsia] Do not Execute paint tasks when there is no vsync (flutter/engine#14298)

* 49d6552 Verify accounting for loop counts in Gif and WebP assets is consistent. (flutter/engine#14321)

* 2ae0d42 Roll src/third_party/dart bcd18e67dcae..bd008dd1e406 (3 commits) (flutter/engine#14322)

* ac95536 Roll src/third_party/skia 5afc7b2af854..75799967be60 (2 commits) (flutter/engine#14324)

* 02fb9c1 Roll src/third_party/dart bd008dd1e406..d9fa37e85d5c (1 commits) (flutter/engine#14325)

* db60ebc Roll fuchsia/sdk/core/mac-amd64 from h4iiT... to otkJA... (flutter/engine#14327)
filmil pushed a commit to filmil/engine that referenced this pull request Mar 13, 2020
Fixes flutter/flutter#19558

This is tested by the devicelab test fast_scroll_large_images__memory
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IO thread GrContext memory needs to be cleaned up
4 participants