[TIMOB-28040] iOS: Make use of shared underlying byte array in Ti.Buffer
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Christopher Williams |
Assignee | Unknown |
Created | 2020-07-23T17:11:44.000+0000 |
Updated | 2020-07-23T17:13:04.000+0000 |
Description
Our current API for Ti.Buffer makes use of an
NSData
. While https://github.com/appcelerator/titanium_mobile/pull/11810 helps us to copy those bytes out to an ArrayBuffer
on the JS side (though Ti.Blob), we should consider retooling Ti.Buffer
to use direct allocation pointing to the same exact memory shared by the JS engine's ArrayBuffer
.
This blog post makes reference to how the J2V8 project did exactly this: https://eclipsesource.com/blogs/2016/07/25/typedarrays-sharing-memory-between-v8-and-java/ for Java/JNI/V8
We could then read/write to the bytes from the native or JS side **without** crossing the native bridge. It would likely require us making Ti.Buffer some extension of ArrayBuffer.
No comments