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

Conversation

harryterkelsen
Copy link
Contributor

Description

Adds caching for allocated CanvasKit objects and deletes the least recently used ones when the cache is full.

Related Issues

Fixes flutter/flutter#56938

Tests

I added the following tests:

Renamed test/canvaskit/util_test.dart to test/canvaskit/skia_object_cache_test.dart and added tests for the caching.

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.

  • I read the contributor guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the C++, Objective-C, Java style guides for the engine.
  • I read the tree hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation.
  • All existing and new tests are passing.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change.

Creates a cache of Skia objects and deletes the least recently used
ones when the cache fills up.

Fixes flutter/flutter#56938
@harryterkelsen harryterkelsen requested a review from yjbanov June 26, 2020 21:53
@auto-assign auto-assign bot requested a review from liyuqian June 26, 2020 21:53
}

/// A [SkiaObject] which is deleted once and cannot be used again.
class OneShotSkiaObject extends SkiaObject {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not abstract like ResurrectableSkiaObject?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everywhere OneShotSkiaObject is used, it's simply a wrapper around a JsObject, so since there was no special logic for resurrecting the JsObject it didn't need to be subclassed.

@harryterkelsen
Copy link
Contributor Author

I made SkParagraph a ResurrectableSkiaObject. PTAL

ui.TextDirection? _textDirection;
String? _fontFamily;
SkParagraphStyle _style;
List<_ParagraphCommand> _commands;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these fields be final?

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.

Flutter Web + CanvasKit crash
3 participants