Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28039] Android: Make use of shared underlying byte array in Ti.Buffer

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterChristopher Williams
AssigneeUnknown
Created2020-07-23T17:11:27.000+0000
Updated2020-07-23T17:11:44.000+0000

Description

Our current API for Ti.Buffer makes use of a byte[]. 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 a ByteBuffer with 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/ Essentially this would involve Ti.Buffer wrapping a ByteBuffer rather than a byte[]. We could then read/write to the bytes from the native or JS side **without** crossing the JNI/V8 native bridge.

Comments

No comments

JSON Source