Nativescript-cli: System.err: TypeError: Cannot read property '_executingContext' of undefined

Created on 22 Jan 2021  ยท  9Comments  ยท  Source: NativeScript/nativescript-cli

Environment

**Describe the bug**
Building a project with  --env.uglify causes the following crash on start:

System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onAnimationEnd failed
System.err: TypeError: Cannot read property '_executingContext' of undefined
System.err:
System.err: StackTrace:
System.err: F(file: node_modules/@nativescript/core/ui/frame/fragment.transitions.android.js:537:40)
System.err: at r.onAnimationEnd(file: node_modules/@nativescript/core/ui/frame/fragment.transitions.android.js:177:8)
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1175)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1153)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1149)
System.err: at com.tns.gen.java.lang.Object_vendor_5941_22_r.onAnimationEnd(Object_vendor_5941_22_r.java:50)
System.err: at android.animation.AnimatorSet.endAnimation(AnimatorSet.java:1301)
System.err: at android.animation.AnimatorSet.doAnimationFrame(AnimatorSet.java:1086)
System.err: at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
System.err: at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
System.err: at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:970)
System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:796)
System.err: at android.view.Choreographer.doFrame(Choreographer.java:727)
System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
System.err: at android.os.Handler.handleCallback(Handler.java:938)
System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
System.err: at android.os.Looper.loop(Looper.java:223)
System.err: at android.app.ActivityThread.main(ActivityThread.java:7660)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

**To Reproduce**
Make sure you have the versions installed as mentioned above and run `ns run android --env.uglify`

% ns create issue-uglify --ts
% ns platform add android
% ns run android --env.uglify
```

Expected behavior
No crash

Most helpful comment

@saschaarthur https://github.com/NativeScript/NativeScript/pull/9165 - you will likely need to recreate config when released, because we enabled Prettier formatting on it - so it changed.

All 9 comments

Does it work fine without the --env.uglify

Yes, it does.

Can you try editing your webpack.config.js file:
Scroll down to the terserOptions and add
keep_classnames: true
like:
image
It should be a descendant of the terserOptions object.

Hi, I can confirm that adding

keep_classnames: platform === 'android',

to the Terser options resolves this crash (I get the same crash as @jessorlisa without this change).

@NathanaelA keep_classnames: true does the trick. โœ…

Strange this issue had not been noticed before releasing the new version. Does nobody really use the uglification option even though it is the recommended step no. 1 to optimize the performance?

I hope the fix will be added to the next release. ๐Ÿ™

@timdoege - if you use keep_classnames: platform === 'android' you probably will get crashes (in other locations on iOS) while running the app as there is other locations where the classname is looked up and when terser rewrites it, it no longer matches. In addition you will get parts of CSS that are not working on iOS. This is one of those items that actually applies to both platforms.

@NathanaelA can we have this fix then in @nativescript/webpack/templates/webpack.angular.js ?

Otherwise we get following warning during our builds:

Note: webpack.config.js is different than the suggested @nativescript/webpack config at .../node_modules/@nativescript/webpack/templates/webpack.angular.js.

@saschaarthur https://github.com/NativeScript/NativeScript/pull/9165 - you will likely need to recreate config when released, because we enabled Prettier formatting on it - so it changed.

Was this page helpful?
0 / 5 - 0 ratings