BabylonNative icon indicating copy to clipboard operation
BabylonNative copied to clipboard

Napi ArrayBuffer constructor behaves inconsistently with undefined

Open CoPrez opened this issue 3 years ago • 1 comments

While testing out the BaseTexture::readPixels() function I found that the behavior of the Napi ArrayBuffer construction at this line was behaving differently in Babylon Native vs Babylon React Native where the implementations of Napi differ.

In Babylon Native the ArrayBuffer construction works as expected and later on IsNull() on the buffer returns true. In Babylon React Native an exception is thrown at that line and the readPixels operation is aborted.

To Reproduce Steps to reproduce the behavior:

  1. In the Babylon React Native playground call readPixels() on a texture with no arguments

Expected behavior The call to readPixels() succeeds

Screenshots If applicable, add screenshots to help explain your problem.

Other Tested on React-Native Android

CoPrez avatar Aug 15 '22 23:08 CoPrez

I tested this with V8 (reference), Chakra, and JSI using the following code:

        auto arg = info[0];
        auto arrayBuffer = arg.As<Napi::ArrayBuffer>();

        auto argIsNull = arg.IsNull();
        (void)argIsNull;

        auto arrayBufferIsNull = arrayBuffer.IsNull();
        (void)arrayBufferIsNull;

V8: argIsNull is true, arrayBufferIsNull is true Chakra: argIsNull is true, arrayBufferIsNull is false JSI: argIsNull is true, arrayBufferIsNull causes assert

These should all be the same.

bghgary avatar Aug 29 '22 21:08 bghgary