getTypedArrayData returns failure for empty buffers
https://github.com/cocos-creator/cocos2d-x-lite/blob/d625446a2d4830d08c1c702d2da9c4e8ca2c4340/cocos/scripting/js-bindings/jswrapper/jsc/Object.cpp#L1044
^ This returns true only if there is data. Considering the function prototype and description I have the length pointer to know if and how much data I have (or if I don't have); I would expect to return false when it FAILS not when it makes arbitrary decisions about how much data I should pass from js. An empty buffer is perfectly valid, this is a breaking change for js bindings.
/**
* @brief Gets backing store of a typed array object.
* @param[out] ptr A temporary pointer to the backing store of a JavaScript Typed Array object.
* @param[out] length The byte length of a JavaScript Typed Array object.
* @return true if succeed, otherwise false.
*/
bool getTypedArrayData(uint8_t** ptr, size_t* length) const;
Also considering that this "hack" in the engine relies on __jsc_getTypedArrayData being registered by jsb_prepare.js an assert or at least an error message when that function is not registered is a lot more appropriate than silently failing with just false as return to find cases when the wrong jsb_prepare.js version is used.
I made that hack function for low version of iOS since there are any native API to create typed array in C++ code in the iOS 10 and lower. We have to wrap the creation of typed array in JS.
Yep, __jsc_getArrayBufferData has to be in jsb_prepare.js since it's the first js that be executed.
You need to make sure jsb_prepare.js being loaded in creator projects.