(iOS) RN Expo Firebase storage upload images - sometimes a random crash during uploading (Dispatch queue: com.facebook.react.NetworkingQueue)

Viewed 208

Expo SDK v42.0.3

Firebase package v8.2.3 (expo install firebase)

We have mobile app made with React Native (expo). In app we are taking photos and then storing them to Firebase storage. App works without problems. But on iOS (testing app with TestFlight) we have detected that app crashes randomly when we are uploading photo to storage. Are we doing something wrong? If you need more info, feel free to ask, I'm a junior and I'm writing for the first time on the forum :) Any help?

When we comment this section of code, everything works fine.

try {
                //const response = await fetch(uri);
                // const blob = await response.blob();
                const blob = await new Promise((resolve, reject) => {
                    const xhr = new XMLHttpRequest();
                    xhr.onload = function () {
                        resolve(xhr.response);
                    };
                    xhr.onerror = function (e) {
                        console.log(e);
                        reject(new TypeError("Network request failed"));
                    };
                    xhr.responseType = "blob";
                    xhr.open("GET", uri, true);
                    xhr.send(null);
                });

                const task = await firebase
                    .storage()
                    .ref()
                    .child(`images/${this.state.gameId}/${this.state.uid}/round${this.state.currentRound}/${photoOfWord}`)
                    .put(blob);

                blob.close()
                const URL = await task.ref.getDownloadURL();

        //realtime db update doesn't cause crash, we use it multiple times in code and it work without problems
                await firebase.database()
                    .ref(this.state.gameId + '/users/' + this.state.uid + '/round' + this.state.currentRound + '_URL')
                    .update({
                        ['word' + photoOfWord + '_URL']: URL
                    });
                
            } catch (error) {
                console.log("ERR ===", error);
             
            }

Error log from iPhone. I copied from the log what I considered important

Date/Time:           2021-09-06 15:52:31.2418 +0200
Launch Time:         2021-09-06 15:51:32.8189 +0200
OS Version:          iPhone OS 14.7.1 (18G82)
Release Type:        User
Baseband Version:    10.80.01
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  2

Thread 2 name:  Dispatch queue: com.facebook.react.NetworkingQueue
Thread 2 Crashed:
0   libsystem_kernel.dylib          0x00000001aff917b0 0x1aff6a000 + 161712
1   libsystem_pthread.dylib         0x00000001cc7349c0 0x1cc72a000 + 43456
2   libsystem_c.dylib               0x000000018cd62ac0 0x18ccef000 + 473792
3   libsystem_c.dylib               0x000000018cd62a44 0x18ccef000 + 473668
4   libc++abi.dylib                 0x0000000197f9abe8 0x197f88000 + 76776
5   libc++abi.dylib                 0x0000000197f8cd14 0x197f88000 + 19732
6   libobjc.A.dylib                 0x0000000197ea09a0 0x197e9a000 + 27040
7   libc++abi.dylib                 0x0000000197f9a074 0x197f88000 + 73844
8   libc++abi.dylib                 0x0000000197f9a00c 0x197f88000 + 73740
9   libdispatch.dylib               0x0000000183d632ac 0x183d02000 + 397996
10  libdispatch.dylib               0x0000000183d0ba40 0x183d02000 + 39488
11  libdispatch.dylib               0x0000000183d0c518 0x183d02000 + 42264
12  libdispatch.dylib               0x0000000183d15fac 0x183d02000 + 81836
13  libsystem_pthread.dylib         0x00000001cc7355bc 0x1cc72a000 + 46524
14  libsystem_pthread.dylib         0x00000001cc73886c 0x1cc72a000 + 59500

Thread 2 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x0000000000000000   x5: 0x0000000000989680   x6: 0x000000000000006e   x7: 0xffffffffffffb749
    x8: 0x000000016f9fb000   x9: 0xf6615b578c3b2d97  x10: 0x00000000000003e8  x11: 0x000000000000000b
   x12: 0x00000001ce99ac4a  x13: 0x0000000000000000  x14: 0x0000000000000010  x15: 0x0000000000000000
   x16: 0x0000000000000148  x17: 0x0000000000000001  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x0000000000004d0f  x21: 0x000000016f9fb0e0  x22: 0x0000000000000114  x23: 0x0000000000000000
   x24: 0x0000000000000000  x25: 0x0000000282ecb100  x26: 0x0000000281569fc0  x27: 0x0000000000000000
   x28: 0x0000000281569fc0   fp: 0x000000016f9fa360   lr: 0x00000001cc7349c0
    sp: 0x000000016f9fa340   pc: 0x00000001aff917b0 cpsr: 0x40000000
   esr: 0x56000080  Address size fault
0 Answers
Related