-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
It is useful for embedders to be able to expose read-only memory regions to Dart code as external type data. This will let Flutter avoid expensive copies on the Dart thread of large amounts of image data, for example see here:
for Image.toByteData:
(The caller of that API could then do a copy to a writable buffer if they need one.)
The best match for this in the Dart SDK appears to be the unmodifiable typed data view classes like UnmodifiableByteDataView. Unfortunately, when these buffers come back into the embedder for various reasons, a call to Dart_TypedDataAcquireData() will fail by returning an error because the Unmodifiable typed data classes don't pass the tests here:
sdk/runtime/vm/dart_api_impl.cc
Line 4065 in f66eb72
| if (!IsExternalTypedDataClassId(class_id) && |
This issue is a feature request to integrate the Unmodifiable typed data classes more seamlessly with the VM so that they're a good match for the read-only buffers we can expose from Flutter as an optimization. If there's another approach that would solve the problem, then I'm interested in that, too.