Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28040] iOS: 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:44.000+0000
Updated2020-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.

Comments

No comments

JSON Source