-
Notifications
You must be signed in to change notification settings - Fork 6k
Use hint freed specifically for image disposal #20754
Conversation
@@ -0,0 +1,97 @@ | |||
|
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.
stray newline
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.
Fixed.
mac flaked out for reasons not related to this test (Xcode install was bad for some reason and then goma failed). Hopefully this gets a clean run for it.
//---------------------------------------------------------------------------- | ||
/// @brief The IO Manager may only be accessed on the IO task runner. | ||
/// | ||
/// @return A weak pointer to the IO manager. | ||
/// | ||
fml::WeakPtr<ShellIOManager> GetIOManager(); | ||
|
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.
I don't know if we care about adding this to the interface. I'm only using it for a test. It's also available through UIDartSate::Current()
, but that requires getting isolate scope.
Also, for future me, the flaky test happened locally with an invocation like:
|
Consider adding this to testing/run_tests.py under a flag (or not) and documenting in https://github.com/flutter/flutter/wiki/Testing-the-engine#unit-tests. |
It looks like this test is slow on Windows CI and will timeout. Not sure if we should disable it for Windows, or increase the timeout there for this test specifically. |
I believe this will pass CI now - it's ready for a review. |
Ok. If I force an idle and reduce the image size a bit, this passes consistently locally, even with throttled down CPU or on a slow windows VM. That way I'm not adding delays. |
lib/ui/painting/canvas.cc
Outdated
@@ -198,7 +198,6 @@ void Canvas::clipPath(const CanvasPath* path, bool doAntiAlias) { | |||
ToDart("Canvas.clipPath called with non-genuine Path.")); | |||
return; | |||
} | |||
external_allocation_size_ += path->path().approximateBytesUsed(); |
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.
Will the engine no longer be reporting these sizes as the external allocation size for Dart objects with native fields? Or does this only affect HintFreed? (Same question here and below.)
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.
Correct. I can split this into another patch, but basically this seems like it was a mistake. We've already moved the reporting of images for this.
The basic problem is that from scene to scene, we might be reusing these things, and end up reporting vastly inflated numbers to the VM, and then that creates lots of wasteful garbage collections.
testing/dart/canvas_test.dart
Outdated
canvas2.drawPicture(picture); | ||
final Picture picture2 = recorder2.endRecording(); | ||
|
||
expect(picture2.approximateBytesUsed, greaterThan(minimumExpected)); |
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.
Would any clients of this API have depended on the old way this was calculated?
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.
It is remotely possible but I strongly doubt it. We should instead find a better way to express this -if they were depending on it, they were probably incorrect, e.g. they were assuming that by disposing the picture they'd be disposing of all that memory which is not necessarily the case.
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.
Moved this to #20950
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.
lgtm
* 5e54c70 Reland: Enable hybrid composition by default on Android (#20722) (flutter/engine#20864) * 9398717 Roll Skia from db5582b71116 to 44e96bee4b6a (4 revisions) (flutter/engine#20908) * 5f49a95 Add auto plugin registration to FlutterFragmentActivity as well (flutter/engine#20865) * c4c4f34 Wait for first frame before checking layer tree (flutter/engine#20910) * 0773bf0 Roll Skia from 44e96bee4b6a to 3913d3e137ed (2 revisions) (flutter/engine#20909) * 8ec8af7 [windows] Add horizontal scroll support (flutter/engine#20668) * 1bd9b8e Reset Shell::weak_factory_gpu_ on the raster thread (flutter/engine#20869) * d67923f Pass text input key events to the EventResponder if they do not yield characters (flutter/engine#20912) * abe10d1 Roll Dart SDK from 84c3eacc7ba0 to 6eab35f49cbb (2 revisions) (flutter/engine#20913) * 101316b [web] migrate from e2e to integration_test (flutter/engine#20914) * 1f52ec3 Roll Dart SDK from 6eab35f49cbb to 2a5f37d25453 (1 revision) (flutter/engine#20917) * 8019058 Default C++ wrapper templates to EncodableValue (flutter/engine#20760) * 5f3ec38 Roll Fuchsia Mac SDK from sI2DAAmSI... to waj2pOhDh... (flutter/engine#20919) * a651020 Roll Fuchsia Linux SDK from _SVZn8uN2... to 9tLNFbjA1... (flutter/engine#20920) * 696c2aa Roll Skia from 3913d3e137ed to 7b46300fe4ff (4 revisions) (flutter/engine#20924) * 95f2b72 Create root isolate asynchronously (flutter/engine#20142) * 58a6207 Adds fuchsia node roles to accessibility bridge updates. (flutter/engine#20385) * a762143 Roll Dart SDK from 2a5f37d25453 to e8e0d5a539fb (3 revisions) (flutter/engine#20928) * 49d6805 Ensure all images are closed in FlutterImageView (flutter/engine#20842) * d67bda7 Image.toByteData and Picture.toImage implementations (#3) (flutter/engine#20750) * 96efe39 Revert "Adds fuchsia node roles to accessibility bridge updates. (#20385)" (flutter/engine#20936) * 5585ed9 Revert "Create root isolate asynchronously (#20142)" (flutter/engine#20937) * f6270c0 Roll Dart SDK from e8e0d5a539fb to b29f228f62e2 (3 revisions) (flutter/engine#20939) * 15bf1bb [Android R] Integrate DisplayCutouts into viewportMetrics (flutter/engine#20921) * 615e668 Clear the GL context only after submitting the frame (flutter/engine#20931) * ca989b8 Roll Skia from 7b46300fe4ff to 1338a37a1add (16 revisions) (flutter/engine#20943) * 8f3f711 Roll Fuchsia Linux SDK from 9tLNFbjA1... to knpSoAoZq... (flutter/engine#20944) * 873c007 Log exception in addition to the stack trace for unhandled exceptions. (flutter/engine#20935) * d761629 Roll Skia from 1338a37a1add to 8fa3b4e8cde5 (6 revisions) (flutter/engine#20949) * f6920da Roll Skia from 8fa3b4e8cde5 to e9a9ad908226 (5 revisions) (flutter/engine#20952) * 634e499 Use hint freed specifically for image disposal (flutter/engine#20754) * c700479 Revert external size changes to Picture (flutter/engine#20950) * 4353797 Roll Skia from e9a9ad908226 to 3d1d636cd839 (6 revisions) (flutter/engine#20955) * 80f4481 renaming e2e tests to integration (flutter/engine#20954) * 61e057a Clear GL context before Gr context (flutter/engine#20957) * f43c3d7 Roll Fuchsia Mac SDK from waj2pOhDh... to 0r88gDzUP... (flutter/engine#20958) * 5a2db33 Roll Skia from 3d1d636cd839 to 683beccf6776 (13 revisions) (flutter/engine#20961) * efb339f Only clear GL context after changing the thread configuration (flutter/engine#20965) * 58d5132 Roll Fuchsia Linux SDK from knpSoAoZq... to odFvFQV9Z... (flutter/engine#20968) * 3729fdb Roll Skia from 683beccf6776 to a66a9c31a318 (4 revisions) (flutter/engine#20969) * 40fe7f3 Roll Fuchsia Mac SDK from 0r88gDzUP... to gOI3W1UNU... (flutter/engine#20970) * e979c29 Roll Skia from a66a9c31a318 to be72801f29f9 (1 revision) (flutter/engine#20971)
* 5e54c70 Reland: Enable hybrid composition by default on Android (#20722) (flutter/engine#20864) * 9398717 Roll Skia from db5582b71116 to 44e96bee4b6a (4 revisions) (flutter/engine#20908) * 5f49a95 Add auto plugin registration to FlutterFragmentActivity as well (flutter/engine#20865) * c4c4f34 Wait for first frame before checking layer tree (flutter/engine#20910) * 0773bf0 Roll Skia from 44e96bee4b6a to 3913d3e137ed (2 revisions) (flutter/engine#20909) * 8ec8af7 [windows] Add horizontal scroll support (flutter/engine#20668) * 1bd9b8e Reset Shell::weak_factory_gpu_ on the raster thread (flutter/engine#20869) * d67923f Pass text input key events to the EventResponder if they do not yield characters (flutter/engine#20912) * abe10d1 Roll Dart SDK from 84c3eacc7ba0 to 6eab35f49cbb (2 revisions) (flutter/engine#20913) * 101316b [web] migrate from e2e to integration_test (flutter/engine#20914) * 1f52ec3 Roll Dart SDK from 6eab35f49cbb to 2a5f37d25453 (1 revision) (flutter/engine#20917) * 8019058 Default C++ wrapper templates to EncodableValue (flutter/engine#20760) * 5f3ec38 Roll Fuchsia Mac SDK from sI2DAAmSI... to waj2pOhDh... (flutter/engine#20919) * a651020 Roll Fuchsia Linux SDK from _SVZn8uN2... to 9tLNFbjA1... (flutter/engine#20920) * 696c2aa Roll Skia from 3913d3e137ed to 7b46300fe4ff (4 revisions) (flutter/engine#20924) * 95f2b72 Create root isolate asynchronously (flutter/engine#20142) * 58a6207 Adds fuchsia node roles to accessibility bridge updates. (flutter/engine#20385) * a762143 Roll Dart SDK from 2a5f37d25453 to e8e0d5a539fb (3 revisions) (flutter/engine#20928) * 49d6805 Ensure all images are closed in FlutterImageView (flutter/engine#20842) * d67bda7 Image.toByteData and Picture.toImage implementations (#3) (flutter/engine#20750) * 96efe39 Revert "Adds fuchsia node roles to accessibility bridge updates. (#20385)" (flutter/engine#20936) * 5585ed9 Revert "Create root isolate asynchronously (#20142)" (flutter/engine#20937) * f6270c0 Roll Dart SDK from e8e0d5a539fb to b29f228f62e2 (3 revisions) (flutter/engine#20939) * 15bf1bb [Android R] Integrate DisplayCutouts into viewportMetrics (flutter/engine#20921) * 615e668 Clear the GL context only after submitting the frame (flutter/engine#20931) * ca989b8 Roll Skia from 7b46300fe4ff to 1338a37a1add (16 revisions) (flutter/engine#20943) * 8f3f711 Roll Fuchsia Linux SDK from 9tLNFbjA1... to knpSoAoZq... (flutter/engine#20944) * 873c007 Log exception in addition to the stack trace for unhandled exceptions. (flutter/engine#20935) * d761629 Roll Skia from 1338a37a1add to 8fa3b4e8cde5 (6 revisions) (flutter/engine#20949) * f6920da Roll Skia from 8fa3b4e8cde5 to e9a9ad908226 (5 revisions) (flutter/engine#20952) * 634e499 Use hint freed specifically for image disposal (flutter/engine#20754) * c700479 Revert external size changes to Picture (flutter/engine#20950) * 4353797 Roll Skia from e9a9ad908226 to 3d1d636cd839 (6 revisions) (flutter/engine#20955) * 80f4481 renaming e2e tests to integration (flutter/engine#20954) * 61e057a Clear GL context before Gr context (flutter/engine#20957) * f43c3d7 Roll Fuchsia Mac SDK from waj2pOhDh... to 0r88gDzUP... (flutter/engine#20958) * 5a2db33 Roll Skia from 3d1d636cd839 to 683beccf6776 (13 revisions) (flutter/engine#20961) * efb339f Only clear GL context after changing the thread configuration (flutter/engine#20965) * 58d5132 Roll Fuchsia Linux SDK from knpSoAoZq... to odFvFQV9Z... (flutter/engine#20968) * 3729fdb Roll Skia from 683beccf6776 to a66a9c31a318 (4 revisions) (flutter/engine#20969) * 40fe7f3 Roll Fuchsia Mac SDK from 0r88gDzUP... to gOI3W1UNU... (flutter/engine#20970) * e979c29 Roll Skia from a66a9c31a318 to be72801f29f9 (1 revision) (flutter/engine#20971) * 6e8930b Roll Skia from be72801f29f9 to f8823b572600 (1 revision) (flutter/engine#20973) * 68b7b84 [fuchsia] Send trace events to system tracing on all configurations (flutter/engine#20974) * 3f05b52 Always set the callback during Rasterizer setup (flutter/engine#20976)
* 5e54c70 Reland: Enable hybrid composition by default on Android (flutter#20722) (flutter/engine#20864) * 9398717 Roll Skia from db5582b71116 to 44e96bee4b6a (4 revisions) (flutter/engine#20908) * 5f49a95 Add auto plugin registration to FlutterFragmentActivity as well (flutter/engine#20865) * c4c4f34 Wait for first frame before checking layer tree (flutter/engine#20910) * 0773bf0 Roll Skia from 44e96bee4b6a to 3913d3e137ed (2 revisions) (flutter/engine#20909) * 8ec8af7 [windows] Add horizontal scroll support (flutter/engine#20668) * 1bd9b8e Reset Shell::weak_factory_gpu_ on the raster thread (flutter/engine#20869) * d67923f Pass text input key events to the EventResponder if they do not yield characters (flutter/engine#20912) * abe10d1 Roll Dart SDK from 84c3eacc7ba0 to 6eab35f49cbb (2 revisions) (flutter/engine#20913) * 101316b [web] migrate from e2e to integration_test (flutter/engine#20914) * 1f52ec3 Roll Dart SDK from 6eab35f49cbb to 2a5f37d25453 (1 revision) (flutter/engine#20917) * 8019058 Default C++ wrapper templates to EncodableValue (flutter/engine#20760) * 5f3ec38 Roll Fuchsia Mac SDK from sI2DAAmSI... to waj2pOhDh... (flutter/engine#20919) * a651020 Roll Fuchsia Linux SDK from _SVZn8uN2... to 9tLNFbjA1... (flutter/engine#20920) * 696c2aa Roll Skia from 3913d3e137ed to 7b46300fe4ff (4 revisions) (flutter/engine#20924) * 95f2b72 Create root isolate asynchronously (flutter/engine#20142) * 58a6207 Adds fuchsia node roles to accessibility bridge updates. (flutter/engine#20385) * a762143 Roll Dart SDK from 2a5f37d25453 to e8e0d5a539fb (3 revisions) (flutter/engine#20928) * 49d6805 Ensure all images are closed in FlutterImageView (flutter/engine#20842) * d67bda7 Image.toByteData and Picture.toImage implementations (flutter#3) (flutter/engine#20750) * 96efe39 Revert "Adds fuchsia node roles to accessibility bridge updates. (flutter#20385)" (flutter/engine#20936) * 5585ed9 Revert "Create root isolate asynchronously (flutter#20142)" (flutter/engine#20937) * f6270c0 Roll Dart SDK from e8e0d5a539fb to b29f228f62e2 (3 revisions) (flutter/engine#20939) * 15bf1bb [Android R] Integrate DisplayCutouts into viewportMetrics (flutter/engine#20921) * 615e668 Clear the GL context only after submitting the frame (flutter/engine#20931) * ca989b8 Roll Skia from 7b46300fe4ff to 1338a37a1add (16 revisions) (flutter/engine#20943) * 8f3f711 Roll Fuchsia Linux SDK from 9tLNFbjA1... to knpSoAoZq... (flutter/engine#20944) * 873c007 Log exception in addition to the stack trace for unhandled exceptions. (flutter/engine#20935) * d761629 Roll Skia from 1338a37a1add to 8fa3b4e8cde5 (6 revisions) (flutter/engine#20949) * f6920da Roll Skia from 8fa3b4e8cde5 to e9a9ad908226 (5 revisions) (flutter/engine#20952) * 634e499 Use hint freed specifically for image disposal (flutter/engine#20754) * c700479 Revert external size changes to Picture (flutter/engine#20950) * 4353797 Roll Skia from e9a9ad908226 to 3d1d636cd839 (6 revisions) (flutter/engine#20955) * 80f4481 renaming e2e tests to integration (flutter/engine#20954) * 61e057a Clear GL context before Gr context (flutter/engine#20957) * f43c3d7 Roll Fuchsia Mac SDK from waj2pOhDh... to 0r88gDzUP... (flutter/engine#20958) * 5a2db33 Roll Skia from 3d1d636cd839 to 683beccf6776 (13 revisions) (flutter/engine#20961) * efb339f Only clear GL context after changing the thread configuration (flutter/engine#20965) * 58d5132 Roll Fuchsia Linux SDK from knpSoAoZq... to odFvFQV9Z... (flutter/engine#20968) * 3729fdb Roll Skia from 683beccf6776 to a66a9c31a318 (4 revisions) (flutter/engine#20969) * 40fe7f3 Roll Fuchsia Mac SDK from 0r88gDzUP... to gOI3W1UNU... (flutter/engine#20970) * e979c29 Roll Skia from a66a9c31a318 to be72801f29f9 (1 revision) (flutter/engine#20971)
* 5e54c70 Reland: Enable hybrid composition by default on Android (flutter#20722) (flutter/engine#20864) * 9398717 Roll Skia from db5582b71116 to 44e96bee4b6a (4 revisions) (flutter/engine#20908) * 5f49a95 Add auto plugin registration to FlutterFragmentActivity as well (flutter/engine#20865) * c4c4f34 Wait for first frame before checking layer tree (flutter/engine#20910) * 0773bf0 Roll Skia from 44e96bee4b6a to 3913d3e137ed (2 revisions) (flutter/engine#20909) * 8ec8af7 [windows] Add horizontal scroll support (flutter/engine#20668) * 1bd9b8e Reset Shell::weak_factory_gpu_ on the raster thread (flutter/engine#20869) * d67923f Pass text input key events to the EventResponder if they do not yield characters (flutter/engine#20912) * abe10d1 Roll Dart SDK from 84c3eacc7ba0 to 6eab35f49cbb (2 revisions) (flutter/engine#20913) * 101316b [web] migrate from e2e to integration_test (flutter/engine#20914) * 1f52ec3 Roll Dart SDK from 6eab35f49cbb to 2a5f37d25453 (1 revision) (flutter/engine#20917) * 8019058 Default C++ wrapper templates to EncodableValue (flutter/engine#20760) * 5f3ec38 Roll Fuchsia Mac SDK from sI2DAAmSI... to waj2pOhDh... (flutter/engine#20919) * a651020 Roll Fuchsia Linux SDK from _SVZn8uN2... to 9tLNFbjA1... (flutter/engine#20920) * 696c2aa Roll Skia from 3913d3e137ed to 7b46300fe4ff (4 revisions) (flutter/engine#20924) * 95f2b72 Create root isolate asynchronously (flutter/engine#20142) * 58a6207 Adds fuchsia node roles to accessibility bridge updates. (flutter/engine#20385) * a762143 Roll Dart SDK from 2a5f37d25453 to e8e0d5a539fb (3 revisions) (flutter/engine#20928) * 49d6805 Ensure all images are closed in FlutterImageView (flutter/engine#20842) * d67bda7 Image.toByteData and Picture.toImage implementations (flutter#3) (flutter/engine#20750) * 96efe39 Revert "Adds fuchsia node roles to accessibility bridge updates. (flutter#20385)" (flutter/engine#20936) * 5585ed9 Revert "Create root isolate asynchronously (flutter#20142)" (flutter/engine#20937) * f6270c0 Roll Dart SDK from e8e0d5a539fb to b29f228f62e2 (3 revisions) (flutter/engine#20939) * 15bf1bb [Android R] Integrate DisplayCutouts into viewportMetrics (flutter/engine#20921) * 615e668 Clear the GL context only after submitting the frame (flutter/engine#20931) * ca989b8 Roll Skia from 7b46300fe4ff to 1338a37a1add (16 revisions) (flutter/engine#20943) * 8f3f711 Roll Fuchsia Linux SDK from 9tLNFbjA1... to knpSoAoZq... (flutter/engine#20944) * 873c007 Log exception in addition to the stack trace for unhandled exceptions. (flutter/engine#20935) * d761629 Roll Skia from 1338a37a1add to 8fa3b4e8cde5 (6 revisions) (flutter/engine#20949) * f6920da Roll Skia from 8fa3b4e8cde5 to e9a9ad908226 (5 revisions) (flutter/engine#20952) * 634e499 Use hint freed specifically for image disposal (flutter/engine#20754) * c700479 Revert external size changes to Picture (flutter/engine#20950) * 4353797 Roll Skia from e9a9ad908226 to 3d1d636cd839 (6 revisions) (flutter/engine#20955) * 80f4481 renaming e2e tests to integration (flutter/engine#20954) * 61e057a Clear GL context before Gr context (flutter/engine#20957) * f43c3d7 Roll Fuchsia Mac SDK from waj2pOhDh... to 0r88gDzUP... (flutter/engine#20958) * 5a2db33 Roll Skia from 3d1d636cd839 to 683beccf6776 (13 revisions) (flutter/engine#20961) * efb339f Only clear GL context after changing the thread configuration (flutter/engine#20965) * 58d5132 Roll Fuchsia Linux SDK from knpSoAoZq... to odFvFQV9Z... (flutter/engine#20968) * 3729fdb Roll Skia from 683beccf6776 to a66a9c31a318 (4 revisions) (flutter/engine#20969) * 40fe7f3 Roll Fuchsia Mac SDK from 0r88gDzUP... to gOI3W1UNU... (flutter/engine#20970) * e979c29 Roll Skia from a66a9c31a318 to be72801f29f9 (1 revision) (flutter/engine#20971) * 6e8930b Roll Skia from be72801f29f9 to f8823b572600 (1 revision) (flutter/engine#20973) * 68b7b84 [fuchsia] Send trace events to system tracing on all configurations (flutter/engine#20974) * 3f05b52 Always set the callback during Rasterizer setup (flutter/engine#20976)
Description
This patch drops some more external size tracking in Picture objects which is almost certainly incorrectly double counting memory.
It adds calls for HintFreed that were dropped in a revert of #19842, but uses them only from
Image::dispose
, which the framework will be taught to call in flutter/flutter#64582Related Issues
flutter/flutter#64582
flutter/flutter#56482
Tests
I added the following tests:
A test that disposes an image it doesn't need in the next frame, and then checks that the native pointer(s) get released.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.