-
Notifications
You must be signed in to change notification settings - Fork 6k
Reland: Avoid a copy in EncodeImage #20003
Reland: Avoid a copy in EncodeImage #20003
Conversation
5a7e3b2
to
8945ad2
Compare
8945ad2
to
e479fb1
Compare
e479fb1
to
400aa98
Compare
I tried this, setting up an isolate as in #18945, but hit a crash in |
@zanderso : you may need to setup the whole shell in order to benchmark engine/shell/common/shell_benchmarks.cc Line 56 in 9398bc4
You may also be able to utilize the
Once the shell is properly set up, you should be able to call
|
Re-run of a flaky Fuchsia job succeeded, so I will land this on red to get things going again. I have a benchmark for this running locally, but I will submit a separate PR for it to keep this one from getting too big. |
* 7f5d044 Wait before switching surfaces (flutter/engine#20100) * 5513273 Reland: Avoid a copy in EncodeImage (flutter/engine#20003) * 1efdd95 Roll Dart SDK from bd528bfbd69d to ea6bde577d1c (19 revisions) (flutter/engine#20172) * 3b0e697 Roll Skia from 8cc118dce813 to c3794dd52778 (27 revisions) (flutter/engine#20173) * cb1a374 Roll Fuchsia Mac SDK from T2xc0OuiK... to i0zTcQ8Qb... (flutter/engine#20175) * ed36b1a Roll Skia from c3794dd52778 to 2d01ed94605a (10 revisions) (flutter/engine#20179) * fcc1eaf Fix iOS Keyboard stuck as UIKeyboardTypeNamePhonePad (flutter/engine#20181) * 9c6837c Roll Skia from 2d01ed94605a to 7225788b9070 (6 revisions) (flutter/engine#20183) * 13e993e Fix Typos (flutter/engine#19691) * 98cfd1d Move platform specific information to `PlatformConfiguration` class (flutter/engine#19652) * 22fb58b update nullability of drawAtlas methods and flesh out docs (flutter/engine#20176) * bcc43df Roll Dart SDK from ea6bde577d1c to 033a81d924b9 (23 revisions) (flutter/engine#20186) * cb4bb93 [web] increase number of shards. sync engine web tests same as flutter repo (flutter/engine#20164) * d986b8d Enable linting in several files (flutter/engine#20134) * 7dd092d Enable more linting (flutter/engine#20187) * 3cc86ac Roll Dart SDK from 033a81d924b9 to ad5bcf16f1c8 (9 revisions) (flutter/engine#20191) * 5ca8a2a Roll Dart SDK from ad5bcf16f1c8 to d169af6f7d8f (1 revision) (flutter/engine#20192) * 4de0c04 Roll Dart SDK from d169af6f7d8f to 7e6c55e3aaf5 (1 revision) (flutter/engine#20196) * 908fe01 Fix navigation message relay. (flutter/engine#20193) * f1b3b69 Roll Dart SDK from 7e6c55e3aaf5 to 365525432a70 (2 revisions) (flutter/engine#20197) * 8fbdd3f Fix parameter names * 083282e Fix Implments typo
* 7f5d044 Wait before switching surfaces (flutter/engine#20100) * 5513273 Reland: Avoid a copy in EncodeImage (flutter/engine#20003) * 1efdd95 Roll Dart SDK from bd528bfbd69d to ea6bde577d1c (19 revisions) (flutter/engine#20172) * 3b0e697 Roll Skia from 8cc118dce813 to c3794dd52778 (27 revisions) (flutter/engine#20173) * cb1a374 Roll Fuchsia Mac SDK from T2xc0OuiK... to i0zTcQ8Qb... (flutter/engine#20175) * ed36b1a Roll Skia from c3794dd52778 to 2d01ed94605a (10 revisions) (flutter/engine#20179) * fcc1eaf Fix iOS Keyboard stuck as UIKeyboardTypeNamePhonePad (flutter/engine#20181) * 9c6837c Roll Skia from 2d01ed94605a to 7225788b9070 (6 revisions) (flutter/engine#20183) * 13e993e Fix Typos (flutter/engine#19691) * 98cfd1d Move platform specific information to `PlatformConfiguration` class (flutter/engine#19652) * 22fb58b update nullability of drawAtlas methods and flesh out docs (flutter/engine#20176) * bcc43df Roll Dart SDK from ea6bde577d1c to 033a81d924b9 (23 revisions) (flutter/engine#20186) * cb4bb93 [web] increase number of shards. sync engine web tests same as flutter repo (flutter/engine#20164) * d986b8d Enable linting in several files (flutter/engine#20134) * 7dd092d Enable more linting (flutter/engine#20187) * 3cc86ac Roll Dart SDK from 033a81d924b9 to ad5bcf16f1c8 (9 revisions) (flutter/engine#20191) * 5ca8a2a Roll Dart SDK from ad5bcf16f1c8 to d169af6f7d8f (1 revision) (flutter/engine#20192) * 4de0c04 Roll Dart SDK from d169af6f7d8f to 7e6c55e3aaf5 (1 revision) (flutter/engine#20196) * 908fe01 Fix navigation message relay. (flutter/engine#20193) * f1b3b69 Roll Dart SDK from 7e6c55e3aaf5 to 365525432a70 (2 revisions) (flutter/engine#20197) * 8fbdd3f Fix parameter names * 083282e Fix Implments typo
* 7f5d044 Wait before switching surfaces (flutter/engine#20100) * 5513273 Reland: Avoid a copy in EncodeImage (flutter/engine#20003) * 1efdd95 Roll Dart SDK from bd528bfbd69d to ea6bde577d1c (19 revisions) (flutter/engine#20172) * 3b0e697 Roll Skia from 8cc118dce813 to c3794dd52778 (27 revisions) (flutter/engine#20173) * cb1a374 Roll Fuchsia Mac SDK from T2xc0OuiK... to i0zTcQ8Qb... (flutter/engine#20175) * ed36b1a Roll Skia from c3794dd52778 to 2d01ed94605a (10 revisions) (flutter/engine#20179) * fcc1eaf Fix iOS Keyboard stuck as UIKeyboardTypeNamePhonePad (flutter/engine#20181) * 9c6837c Roll Skia from 2d01ed94605a to 7225788b9070 (6 revisions) (flutter/engine#20183) * 13e993e Fix Typos (flutter/engine#19691) * 98cfd1d Move platform specific information to `PlatformConfiguration` class (flutter/engine#19652) * 22fb58b update nullability of drawAtlas methods and flesh out docs (flutter/engine#20176) * bcc43df Roll Dart SDK from ea6bde577d1c to 033a81d924b9 (23 revisions) (flutter/engine#20186) * cb4bb93 [web] increase number of shards. sync engine web tests same as flutter repo (flutter/engine#20164) * d986b8d Enable linting in several files (flutter/engine#20134) * 7dd092d Enable more linting (flutter/engine#20187) * 3cc86ac Roll Dart SDK from 033a81d924b9 to ad5bcf16f1c8 (9 revisions) (flutter/engine#20191) * 5ca8a2a Roll Dart SDK from ad5bcf16f1c8 to d169af6f7d8f (1 revision) (flutter/engine#20192) * 4de0c04 Roll Dart SDK from d169af6f7d8f to 7e6c55e3aaf5 (1 revision) (flutter/engine#20196) * 908fe01 Fix navigation message relay. (flutter/engine#20193) * f1b3b69 Roll Dart SDK from 7e6c55e3aaf5 to 365525432a70 (2 revisions) (flutter/engine#20197) * 8fbdd3f Fix parameter names * 083282e Fix Implments typo
Description
While working on a hobby project, I noticed that
image.toByteData(format: ui.ImageByteFormat.png)
is quite slow for large images (>4s for a 1080p image on a Nexus 5x). Most of that work is not on the Dart thread, but the final copy into a Dart heapUint8List
appeared to be, and was taking ~1.5s.Instead of doing that last copy, this PR creates an external typed data object instead.
This is a reland of #19504. The buffer is not allocated in read-only memory, skia will not write it, and it is owned by Dart on return, so it does not need to be an
UnmodifiableByteDataView
. It can still beUint8List
.Tests
I added the following tests:
image_encoding_unittests.cc
Breaking Change
Did any tests fail when you ran them? Please read [handling breaking changes].