-
Notifications
You must be signed in to change notification settings - Fork 6k
[skwasm] encode PNGs using browser APIs #45187
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
offscreenCanvas.getContext('bitmaprenderer')! as DomCanvasRenderingContextBitmapRenderer; | ||
context.transferFromImageBitmap(bitmap); | ||
final DomBlob blob = await offscreenCanvas.convertToBlob(); | ||
final JSArrayBuffer arrayBuffer = (await blob.arrayBuffer().toDart)! as JSArrayBuffer; |
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.
Once we have the bytes of the image, should we set offscreenCanvas.height/width
to zero so the browser can eagerly reclaim the bitmap memory? Otherwise, the browser may have to wait for the GC cycle to kick in. In the past, Safari would run out of memory if we didn't zero out the canvas, and return null
when creating a new canvas.
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.
Good idea. I'll do that
test-exempt: code refactor with no semantic change |
…133518) flutter/engine@bd2132a...45e2b41 2023-08-28 jacksongardner@google.com [skwasm] encode PNGs using browser APIs (flutter/engine#45187) 2023-08-28 skia-flutter-autoroll@skia.org Roll Dart SDK from 5d3ab5db5037 to 2900ad211f38 (3 revisions) (flutter/engine#45192) 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 jimgraham@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose 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/+doc/main/autoroll/README.md
This allows us to remove libpng from skia entirely, which saves us about 25kb brotli compressed. Note, this should not change any functionality. The existing functionality is covered by the unit tests here: https://github.com/flutter/engine/blame/bd2132a0814f6df95471e97f7d5efaca515506bd/lib/web_ui/test/ui/image_golden_test.dart#L197-L197
This allows us to remove libpng from skia entirely, which saves us about 25kb brotli compressed.
Note, this should not change any functionality. The existing functionality is covered by the unit tests here: https://github.com/flutter/engine/blame/bd2132a0814f6df95471e97f7d5efaca515506bd/lib/web_ui/test/ui/image_golden_test.dart#L197-L197