leb128_1.lebEncode issue in react-native

Hi,

There is an issue on react native that using IDL.encode (which is used in creating arg parameter) gets stuck. I narrowed down the problem and it is because of ‘leb128_1.lebEncode’. I am trying to findout the issue unless someone already knows the answer?

It seems it is stuck in this loop inside function lebEncode:

while (true) {
        const i = Number(value & BigInt(0x7f));
        value /= BigInt(0x80);
        if (value === BigInt(0)) {
            pipe.write([i]);
            break;
        }
        else {
            pipe.write([i | 0x80]);
        }
    }

inside while, BigInt comparison does not work as expected in react native. changin the equality line to below would fix it:

if (BigInt(0).equals(value)) {

Are you running this in a simulator or on-device? Android or iOS? With a custom JS engine or the default one? With a BigInt polyfill or without?

I’ve been passing BigInts to my canister backend in React Native without problem. I wonder maybe it’s your environment?

1 Like

I am running it on Android physical device, with the default engine and with BigInt polyfill. Is this the same environment you ran? From your earlier comments on antoher post I believe you use custom engine ?

Ah yeah, I’m using a custom v8 engine. I tried a bunch of BigInt polyfills and they were way too slow. The only one that was fast enough was JSBI, but it requires some pretty hefty syntax changes, so I ended up going with v8 instead. Which polyfill are you using?

I am using ‘big-integer’. any insights on the speed of this?
big-integer - npm (npmjs.com)

Yeah, I don’t think this one worked for me. I forgot it it was due to an error or performance.

1 Like