NativeScript / nativescript-app-sync

♻️ Update your app without going through the app store!
MIT License
125 stars 24 forks source link

iOS Crash when using "--mandatory" with NativeScript-Vue #54

Open vpulim opened 4 years ago

vpulim commented 4 years ago

The app crashes on an appsync update when using NativeScript Vue. I've created a repo based on the vue template app for reproducing this: https://github.com/vpulim/appsync-crash

I ran the following commands:

nativescript-app-sync app add AppSyncCrash ios
tns run ios --release
# modify App.vue
tns build ios --release
nativescript-app-sync release AppSyncCrash ios --mandatory

The stack trace is here:

Cannot be called with asCopy = NO on non-main thread.
Cannot be called with asCopy = NO on non-main thread.
Cannot be called with asCopy = NO on non-main thread.
+[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior. trace=(
0   UIKitCore                           0x000000019f252c40 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 15633472
1   UIKitCore                           0x000000019f252cd8 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 15633624
2   libdispatch.dylib                   0x000000019a951fd8 0C7A69CD-F2EE-3426-BFD8-742C903D3D07 + 12248
3   libdispatch.dylib                   0x000000019a9536c0 0C7A69CD-F2EE-3426-BFD8-742C903D3D07 + 18112
4   UIKitCore                           0x000000019f252bc4 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 15633348
5   UIKitCore                           0x000000019f252d44 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 15633732
6   UIKitCore                           0x000000019f1734c4 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 14718148
7   UIKitCore                           0x000000019f173408 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 14717960
8   UIKitCore                           0x000000019e3a20ac AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 229548
9   UIKitCore                           0x000000019e3a1494 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 226452
10  UIKitCore                           0x000000019e38f9f4 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 154100
11  UIKitCore                           0x000000019e38cf30 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 143152
12  UIKitCore                           0x000000019e38d00c AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 143372
13  UIKitCore                           0x000000019e3b80c4 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 319684
14  UIKitCore                           0x000000019e3d8c08 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 453640
15  UIKitCore                           0x000000019e3d7dbc AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 449980
16  UIKitCore                           0x000000019e3d7d38 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 449848
17  UIKitCore                           0x000000019e3c1224 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 356900
18  UIKitCore                           0x000000019e768a1c AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 4188700
19  UIKitCore                           0x000000019e769104 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 4190468
20  UIKitCore                           0x000000019e77f214 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 4280852
21  UIKitCore                           0x000000019e777d08 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 4250888
22  UIKitCore                           0x000000019e77975c AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 4257628
23  UIKitCore                           0x000000019e77bd0c AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 4267276
24  UIKitCore                           0x000000019e77c270 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 4268656
25  UIKitCore                           0x000000019e77bc58 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 4267096
26  UIKitCore                           0x000000019e77beec AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 4267756
27  NativeScript                        0x00000001059e0044 ffi_call_SYSV + 68
28  NativeScript                        0x00000001059dd780 ffi_call_int + 1272
29  NativeScript                        0x00000001059dd27c ffi_call + 56
30  NativeScript                        0x0000000104e80f54 _ZN12NativeScript15FunctionWrapper4callEPN3JSC9ExecStateE + 752
31  NativeScript                        0x00000001059dc488 llint_entry + 89928
32  NativeScript                        0x00000001059da804 llint_entry + 82628
33  NativeScript                        0x00000001059da804 llint_entry + 82628
34  NativeScript                        0x00000001059da804 llint_entry + 82628
35  NativeScript                        0x00000001059c62ac vmEntryToJavaScript + 268
36  NativeScript                        0x0000000105653ebc _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 548
37  NativeScript                        0x0000000105016b50 _ZN3JSC9JSPromise10initializeEPNS_9ExecStateEPNS_14JSGlobalObjectENS_7JSValueE + 264
38  NativeScript                        0x0000000105017508 _ZN3JSCL16constructPromiseEPNS_9ExecStateE + 340
39  NativeScript                        0x00000001059dc5d0 llint_entry + 90256
40  NativeScript                        0x00000001059db1f8 llint_entry + 85176
41  NativeScript                        0x00000001059da804 llint_entry + 82628
42  NativeScript                        0x00000001059da804 llint_entry + 82628
43  NativeScript                        0x00000001059da804 llint_entry + 82628
44  NativeScript                        0x00000001059c62ac vmEntryToJavaScript + 268
45  NativeScript                        0x0000000105653ebc _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 548
46  NativeScript                        0x0000000104e80074 _ZN12NativeScript11FFICallbackINS_17ObjCBlockCallbackEE12callFunctionERKN3JSC7JSValueERKNS3_7ArgListEPv + 148
47  NativeScript                        0x0000000104ed1f44 _ZN12NativeScript17ObjCBlockCallback18ffiClosureCallbackEPvPS1_S1_ + 200
48  NativeScript                        0x0000000104ed23c8 _ZN12NativeScript11FFICallbackINS_17ObjCBlockCallbackEE18ffiClosureCallbackEP7ffi_cifPvPS5_S5_ + 104
49  NativeScript                        0x00000001059de05c ffi_closure_SYSV_inner + 996
50  NativeScript                        0x00000001059e01b4 .Ldo_closure + 20
51  AppSync                             0x0000000104c0255c +[SSZipArchive unzipFileAtPath:toDestination:preserveAttributes:overwrite:password:error:delegate:progressHandler:completionHandler:] + 7896
52  AppSync                             0x0000000104c004d0 +[SSZipArchive unzipFileAtPath:toDestination:progressHandler:completionHandler:] + 204
53  AppSync                             0x0000000104c1c9f8 __66+[TNSAppSync unzipFileAtPath:toDestination:onProgress:onComplete:]_block_invoke + 184
54  libdispatch.dylib                   0x000000019a950b7c 0C7A69CD-F2EE-3426-BFD8-742C903D3D07 + 7036
55  libdispatch.dylib                   0x000000019a951fd8 0C7A69CD-F2EE-3426-BFD8-742C903D3D07 + 12248
56  libdispatch.dylib                   0x000000019a954414 0C7A69CD-F2EE-3426-BFD8-742C903D3D07 + 21524
57  libdispatch.dylib                   0x000000019a960bd4 0C7A69CD-F2EE-3426-BFD8-742C903D3D07 + 72660
58  libdispatch.dylib                   0x000000019a961384 0C7A69CD-F2EE-3426-BFD8-742C903D3D07 + 74628
59  libsystem_pthread.dylib             0x000000019a9b7690 _pthread_wqthread + 216
60  libsystem_pthread.dylib             0x000000019a9bd9e8 start_wqthread + 8
)
Unsupported use of UIKit view-customization API off the main thread. -setHasDimmingView: sent to <_UIAlertControllerView: 0x105f24350; frame = (0 0; 375 812); layer = <CALayer: 0x2822a6360>>
Unsupported use of UIKit view-customization API off the main thread. -setShouldHaveBackdropView: sent to <_UIAlertControllerView: 0x105f24350; frame = (0 0; 375 812); layer = <CALayer: 0x2822a6360>>
Cannot be called with asCopy = NO on non-main thread.
Unsupported use of UIKit view-customization API off the main thread. -setAlignsToKeyboard: sent to <_UIAlertControllerView: 0x105f24350; frame = (0 0; 375 812); layer = <CALayer: 0x2822a6360>>
This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
Stack:(
0   Foundation                          0x000000019b198550 7A7A96AF-79E4-3DB1-8904-42E61CAE8999 + 2331984
1   Foundation                          0x000000019af87828 7A7A96AF-79E4-3DB1-8904-42E61CAE8999 + 165928
2   UIKitCore                           0x000000019f186250 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 14795344
3   UIKitCore                           0x000000019f187648 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 14800456
4   UIKitCore                           0x000000019e3dfd74 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 482676
5   UIKitCore                           0x000000019e3db4b8 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 464056
6   UIKitCore                           0x000000019e3db72c AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 464684
7   UIKitCore                           0x000000019e3dba6c AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 465516
8   UIKitCore                           0x000000019e3e0630 AAFEFEBE-C172-3346-8972-810EB8F2F2C6 + 484912
9   UIKitCore                           0x000000019e3
NativeScript caught signal 11.
Native Stack:
1   0x104efcb18 sig_handler(int)
2   0x19a9b3424 <redacted>
3   0x1045cf894
4   0x1045cf894
5   0x19acacc7c <redacted>
6   0x19a9c52fc <redacted>
7   0x19aa6b634 <redacted>
8   0x19aa6af58 __cxa_get_exception_ptr
9   0x19aa6af10 <redacted>
10  0x19a9c5158 <redacted>
11  0x19b1985e0 <redacted>
12  0x19af87828 <redacted>
13  0x19f186250 <redacted>
14  0x19f187648 <redacted>
15  0x19e3dfd74 <redacted>
16  0x19e3db4b8 <redacted>
17  0x19e3db72c <redacted>
18  0x19e3dba6c <redacted>
19  0x19e3e0630 <redacted>
20  0x19e3e0474 <redacted>
21  0x19e3c1364 <redacted>
22  0x19e768a1c <redacted>
23  0x19e769104 <redacted>
24  0x19e77f214 <redacted>
25  0x19e777d08 <redacted>
26  0x19e77975c <redacted>
27  0x19e77bd0c <redacted>
28  0x19e77c270 <redacted>
29  0x19e77bc58 <redacted>
30  0x19e77beec <redacted>
31  0x1059e0044 ffi_call_SYSV

The only change I made to the sample vue app is:

<script >
  import { AppSync, InstallMode, SyncStatus } from 'nativescript-app-sync'
  import * as application from 'tns-core-modules/application'

  export default {
    data() {
      return {
        msg: 'Hello World!'
      }
    },
    created () {
      application.on(application.resumeEvent, () => {
        AppSync.sync({
          deploymentKey: 'INSERT KEY HERE',
          installMode: InstallMode.ON_NEXT_RESUME,
          mandatoryInstallMode: InstallMode.IMMEDIATE
        }, (syncStatus, updateLabel) => {
          console.log('**** APPSYNC STATUS:', syncStatus)
          if (syncStatus === SyncStatus.UP_TO_DATE) {
            console.log('**** APPSYNC: UP-TO-DATE')
          } else if (syncStatus === SyncStatus.UPDATE_INSTALLED) {
            console.log('**** APPSYNC: UPDATE INSTALLED:', updateLabel)
          }
        })
      })
    }
  }
</script>
EddyVerbruggen commented 4 years ago

Can you try with mandatoryInstallMode: InstallMode.ON_NEXT_RESUME (at least for iOS)?

vpulim commented 4 years ago

ON_NEXT_RESUME does fix the issue. Is this a limitation on iOS?

EddyVerbruggen commented 4 years ago

Not really. That stacktrace made me wonder if it's a timing issue for showing the alert that's associated with the IMMEDIATE flow. And if this is an AppStore distributed app then you should not prompt the user to kill their app anyway.

vpulim commented 4 years ago

This is for an Enterprise customer unfortunately and we need a way to ensure patches/bug fixes gets rolled out immediately. Happy to help debug further if needed, and thank you for the awesome work on this plugin!

EddyVerbruggen commented 4 years ago

Not sure what to do without diving into this (no time unfortunately).. maybe wrap that entire AppSync.sync({ thingy in a timeout of a second?