Skip to content

Conversation

@polina-c
Copy link
Contributor

@polina-c polina-c commented Sep 13, 2023

_RenderChip should not create new layer to push opacity.
TestRecordingPaintingContext, TestClipPaintingContext should dispose created Layers.

@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. labels Sep 13, 2023
@polina-c polina-c changed the title Clean up leaks in paining layers. paining layers - draft Sep 14, 2023
void dispose() {
for (final OpacityLayer layer in _createdLayers) {
layer.dispose();
}
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look right. I believe, the caller of pushOpacity assumes ownership of the OpacityLayer and should be in charge of disposing it, not the PaintContext.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This thing is just for testing.
And, i think it is reasonable to ask test to dispose the instance of created TestRecordingPaintingContext, at the end of the test.

Otherwise, it should return the layer somehow, that means change of contract.


TestClipPaintingContext._(this._layer) : super(_layer, Rect.zero);

ContainerLayer _layer = ContainerLayer();
Copy link
Member

Choose a reason for hiding this comment

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

Do you need this default value? Looks like in all code paths it's always overridden? Also, should this field be final?

Copy link
Contributor Author

@polina-c polina-c Sep 14, 2023

Choose a reason for hiding this comment

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

Yes, i need just one created in constructor. Thanks.

final int disabledColorAlpha = disabledColor.alpha;
if (needsCompositing) {
context.pushLayer(OpacityLayer(alpha: disabledColorAlpha), paintWithOverlay, offset);
context.pushOpacity(offset, disabledColorAlpha, paintWithOverlay);
Copy link
Member

@goderbauer goderbauer Sep 14, 2023

Choose a reason for hiding this comment

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

I believe you need to hold on to the layer this method returns, see https://master-api.flutter.dev/flutter/rendering/LayerHandle-class.html (and probably other invocations of this method).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. This PR is not ready yet. I've split it to number of smaller ones, so that I can see what changes cause failures. Will link your comments there:
#134708
#134768

@polina-c polina-c changed the title paining layers - draft painting layers - draft Sep 15, 2023
@polina-c polina-c added the a: leak tracking Issues and PRs related to memory leaks detected by leak_tracker label Sep 21, 2023
@polina-c
Copy link
Contributor Author

polina-c commented Oct 4, 2023

The issue is fixed by other prs. Closing.

@polina-c polina-c closed this Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: leak tracking Issues and PRs related to memory leaks detected by leak_tracker a: tests "flutter test", flutter_test, or one of our tests f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants