-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[web] Make Canvaskit's malloc more useful #38130
Conversation
58198e8
to
5e7c3b7
Compare
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.
|
||
/// Allocates a [Float32List] backed by WASM memory, managed by | ||
/// a [SkFloat32List]. | ||
/// | ||
/// To free the allocated array use [freeFloat32List]. | ||
/// To free the allocated array use [freeList]. | ||
SkFloat32List mallocFloat32List(int size) { |
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.
Let's document if size
is in bytes or element count. Also, if it's the latter, then perhaps length
is a more idiomatic name for the parameter (and I think sizeInBytes
is more common for the other one).
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'll check what CanvasKit calls the parameter.
/// | ||
/// The [list] is no longer usable after calling this function. | ||
/// | ||
/// Use this function to free lists owned by the engine. | ||
@JS('window.flutterCanvasKit.Free') | ||
external void freeFloat32List(SkFloat32List list); | ||
external void freeList(_MallocObj list); |
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's strange for a public function to take a private type. Can _MallocObj
be public?
Also, nit: avoid abbreviations - MallocObject
.
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.
Sure, I'll make it public.
As for the abbreviation, I used whatever name CanvasKit uses: https://github.com/google/skia/blob/0e95fd2482f8a456b2bcabf350efd51a042c3b97/modules/canvaskit/npm_build/types/index.d.ts#L786
/// | ||
/// The [list] is no longer usable after calling this function. | ||
/// | ||
/// Use this function to free lists owned by the engine. | ||
@JS('window.flutterCanvasKit.Free') | ||
external void freeFloat32List(SkFloat32List list); | ||
external void freeList(_MallocObj list); |
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.
nit: do we need List
in the name? In the future, we could extend the API to include other malloc-ed types, including non-List kinds, no?
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.
We don't need List
in the name. I'll remove it.
auto label is removed for flutter/engine, pr: 38130, due to - The status or check suite Linux Web Framework tests has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…117109) * 1a1b1feee Roll Skia from 537e1e8c1ca6 to 729ccbfb87bc (7 revisions) (flutter/engine#38277) * 3b18821e1 Roll Fuchsia Linux SDK from A0jnUUORf2LQu1z2V... to e2lfUFBW5ddtTZBbw... (flutter/engine#38280) * beb94ea2c Roll Skia from 729ccbfb87bc to 3171deabd88a (4 revisions) (flutter/engine#38279) * 8f9071ab9 Roll Fuchsia Mac SDK from FQQdl8AGAsALFniHl... to u-tC0QEGUT4xQ4KOo... (flutter/engine#38282) * aa78cd8d6 add link to website (flutter/engine#38273) * 955447b35 pylint all Python scripts under testing/ (flutter/engine#38268) * 3f22e1958 [web] correct float count in runtime effect (flutter/engine#38288) * 479bb736f Fix issues related to keyboard inset (flutter/engine#37719) * 6cd85616b [macOS] Refactor rendering infrastructure (flutter/engine#37789) * d1533d12b [web] Make Canvaskit's malloc more useful (flutter/engine#38130) * db5605ea7 Fix new `unnecessary_parenthesis` diagnostics. (flutter/engine#38291)
* [web] Make Canvaskit's malloc more useful * address review comments
* [web] Make Canvaskit's malloc more useful * address review comments
…lutter#117109) * 1a1b1feee Roll Skia from 537e1e8c1ca6 to 729ccbfb87bc (7 revisions) (flutter/engine#38277) * 3b18821e1 Roll Fuchsia Linux SDK from A0jnUUORf2LQu1z2V... to e2lfUFBW5ddtTZBbw... (flutter/engine#38280) * beb94ea2c Roll Skia from 729ccbfb87bc to 3171deabd88a (4 revisions) (flutter/engine#38279) * 8f9071ab9 Roll Fuchsia Mac SDK from FQQdl8AGAsALFniHl... to u-tC0QEGUT4xQ4KOo... (flutter/engine#38282) * aa78cd8d6 add link to website (flutter/engine#38273) * 955447b35 pylint all Python scripts under testing/ (flutter/engine#38268) * 3f22e1958 [web] correct float count in runtime effect (flutter/engine#38288) * 479bb736f Fix issues related to keyboard inset (flutter/engine#37719) * 6cd85616b [macOS] Refactor rendering infrastructure (flutter/engine#37789) * d1533d12b [web] Make Canvaskit's malloc more useful (flutter/engine#38130) * db5605ea7 Fix new `unnecessary_parenthesis` diagnostics. (flutter/engine#38291)
Open up Canvaskit's malloc to be used for other types of lists, not just float32.