Async-storage: Async Storage cause thread crash on specifics versions of iOS

Created on 22 Jul 2019  ยท  11Comments  ยท  Source: react-native-async-storage/async-storage

Hi everyone !

I'm actually working on an react-native app using async storage and since I update my environment (react-native version, package, etc) the application crash on specific versions of iOS (actually working on Android) when it try to access data with AsyncStorage.

Environment

  • Async Storage version: 1.5.0
  • React-Native version: 0.59.9
  • Platform tested: not working on iPad iOS 12.1.4, works on iPad (iOS 10.1.1), iPhone (iOS 12.3.1) and Android
  • Logs/Error that are relevant:
    AppleDeveloper send to me three logs files, you can see the parts showing the problem below:

File 1:
Thread 1 name: Dispatch queue: com.facebook.react.AsyncLocalStorageQueue
Thread 1 Crashed:
0 libsystem_kernel.dylib 0x0000000219d2d0dc 0x219d0a000 + 143580
1 libsystem_pthread.dylib 0x0000000219da6094 0x219da4000 + 8340
2 libsystem_c.dylib 0x0000000219c86ea8 0x219c2c000 + 372392
3 libc++abi.dylib 0x0000000219353788 0x219352000 + 6024
4 libc++abi.dylib 0x0000000219353934 0x219352000 + 6452
5 libobjc.A.dylib 0x000000021936ae00 0x219365000 + 24064
6 libc++abi.dylib 0x000000021935f838 0x219352000 + 55352
7 libc++abi.dylib 0x000000021935f8c4 0x219352000 + 55492
8 libdispatch.dylib 0x0000000219bd07e8 0x219b70000 + 395240
9 libdispatch.dylib 0x0000000219b79320 0x219b70000 + 37664
10 libdispatch.dylib 0x0000000219b79e3c 0x219b70000 + 40508
11 libdispatch.dylib 0x0000000219b824a8 0x219b70000 + 74920
12 libsystem_pthread.dylib 0x0000000219db0114 0x219da4000 + 49428
13 libsystem_pthread.dylib 0x0000000219db2cd4 0x219da4000 + 60628

File 2 :
Thread 1 name: Dispatch queue: com.facebook.react.AsyncLocalStorageQueue
Thread 1 Crashed:
0 libsystem_kernel.dylib 0x0000000219d2d0dc 0x219d0a000 + 143580
1 libsystem_pthread.dylib 0x0000000219da6094 0x219da4000 + 8340
2 libsystem_c.dylib 0x0000000219c86ea8 0x219c2c000 + 372392
3 libc++abi.dylib 0x0000000219353788 0x219352000 + 6024
4 libc++abi.dylib 0x0000000219353934 0x219352000 + 6452
5 libobjc.A.dylib 0x000000021936ae00 0x219365000 + 24064
6 libc++abi.dylib 0x000000021935f838 0x219352000 + 55352
7 libc++abi.dylib 0x000000021935f8c4 0x219352000 + 55492
8 libdispatch.dylib 0x0000000219bd07e8 0x219b70000 + 395240
9 libdispatch.dylib 0x0000000219b79320 0x219b70000 + 37664
10 libdispatch.dylib 0x0000000219b79e3c 0x219b70000 + 40508
11 libdispatch.dylib 0x0000000219b824a8 0x219b70000 + 74920
12 libsystem_pthread.dylib 0x0000000219db0114 0x219da4000 + 49428
13 libsystem_pthread.dylib 0x0000000219db2cd4 0x219da4000 + 60628

File 3 :
Thread 2 name: Dispatch queue: com.facebook.react.AsyncLocalStorageQueue
Thread 2 Crashed:
0 libsystem_kernel.dylib 0x0000000219d2d0dc 0x219d0a000 + 143580
1 libsystem_pthread.dylib 0x0000000219da6094 0x219da4000 + 8340
2 libsystem_c.dylib 0x0000000219c86ea8 0x219c2c000 + 372392
3 libc++abi.dylib 0x0000000219353788 0x219352000 + 6024
4 libc++abi.dylib 0x0000000219353934 0x219352000 + 6452
5 libobjc.A.dylib 0x000000021936ae00 0x219365000 + 24064
6 libc++abi.dylib 0x000000021935f838 0x219352000 + 55352
7 libc++abi.dylib 0x000000021935f8c4 0x219352000 + 55492
8 libdispatch.dylib 0x0000000219bd07e8 0x219b70000 + 395240
9 libdispatch.dylib 0x0000000219b79320 0x219b70000 + 37664
10 libdispatch.dylib 0x0000000219b79e3c 0x219b70000 + 40508
11 libdispatch.dylib 0x0000000219b824a8 0x219b70000 + 74920
12 libsystem_pthread.dylib 0x0000000219db0114 0x219da4000 + 49428
13 libsystem_pthread.dylib 0x0000000219db2cd4 0x219da4000 + 60628

Hope this logs can help you to understand my problem
Thanks for your help.

iOS

Most helpful comment

@tido64 Correct, Async Storage requires data to be a string on iOS.

All 11 comments

Hi @mdazi ,

Unfortunately, they don't tell me much. Something's happening in AsyncLocalStorageQueue, but can't tell what exactly, as we miss error information. Can you provide that?

Hi @Krizzu, thanks for your reply ๐Ÿ™‚
All I have for now are the log files provide by Apple, how can I provide you the needed information ?

Normally there's a crash error next to logs you provided, pointing to what happend exactly

application-logs
You can see one of the logs file that Apple send to me, I don't have the competences to read them correctly, hoping what you looking for for help me are on it.

@mdazi Do you have the console logs as well? These aren't very helpful without debug symbols. It also seems like it crashes deep inside the platform, so it's hard to say whether it is actually caused by us.

Sorry for the late, needed time to get an iPad with the last version and test on it... The problem is when I test my app on my device the error doesn't happened so I tried again to submit it to Apple but always the same problem. I come back to you when the error will be trigger.

Hi @tido64, @Krizzu, I success to trigger the error, this is what the console show for the crash :

Exception '-[__NSCFNumber length]: unrecognized selector sent to instance 0x83d5218ad5127bc0' was thrown while invoking multiSet on target RNCAsyncStorage with params (
        (
                (
            "default_city",
            1
        )
    ),
    409
)
callstack: (
    0   CoreFoundation                      0x0000000193a999a4 <redacted> + 252
    1   libobjc.A.dylib                     0x0000000192c729f8 objc_exception_throw + 56
    2   CoreFoundation                      0x00000001939b61c8 <redacted> + 0
    3   CoreFoundation                      0x0000000193a9f1d4 <redacted> + 1408
    4   CoreFoundation                      0x0000000193aa0e6c _CF_forwarding_prep_0 + 92
    5   Citicks                             0x000000010077be14 _ZN5folly6detail8function14FunctionTraitsIKFbRKNS_7dynamicES5_EE10uninitCallERNS1_4DataES5_S5_ + 82500
    6   Citicks                             0x000000010077cd40 _ZN5folly6detail8function14FunctionTraitsIKFbRKNS_7dynamicES5_EE10uninitCallERNS1_4DataES5_S5_ + 86384
    7   Co<โ€ฆ>

the code I concerned by the error is :

_acceptDefaultCity(){
    try{
      !this.isCancelled && this.setState({
        modalVisible: false
      });
      var cityClicked = this.state.cityClicked.id;
      return AsyncStorage.setItem('default_city', cityClicked, () => {
        this.redirectCity();
      });
    }catch(error){
      console.log('error : _acceptDefaultCity');
    }  
  }

As a reminder, this code work on the iPad with XCode but not when the app is compiled (with .ipa file)
Thanks a lot for your help !

Is id a non-string value? I don't think AsyncStorage supports anything but strings. @Krizzu correct me if I'm wrong.

@tido64 Correct, Async Storage requires data to be a string on iOS.

Indeed, it was that, it's working now !
Thanks a lot for your help !!! ๐Ÿ˜ƒ ๐ŸŽ‰ ๐ŸŽ‰

Why would it not crash when building from Xcode then?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rogueturnip picture rogueturnip  ยท  27Comments

Waqas-Jani picture Waqas-Jani  ยท  28Comments

Alaa-Ben picture Alaa-Ben  ยท  20Comments

Krizzu picture Krizzu  ยท  36Comments

dominiczaq picture dominiczaq  ยท  22Comments