NativeScript: Changing font-size / display-size in combination with BottomNavigation causes crash
Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):
- CLI: 6.2.0
- Cross-platform modules:
- tns-android: 6.2.0
- Android Runtime:
- Devices with Android 8, 9, and 10.
Describe the bug
Changing accessibility font-size within the context of a BottomNavigation causes a runtime error.
System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onStart failed
System.err: Error: java.lang.IllegalArgumentException: No view found for id 0x2 (unknown) for fragment FragmentBase_vendor_15352_26_TabFragmentImplementation{54a9e51 #1 id=0x2 android:bottomnavigation:2:1}
System.err:
System.err: StackTrace:
System.err: BottomNavigation.commitCurrentTransaction(file:///node_modules/@nativescript/core/ui/bottom-navigation/bottom-navigation.js:347:37)
System.err: at BottomNavigation.changeTab(file:///node_modules/@nativescript/core/ui/bottom-navigation/bottom-navigation.js:361:13)
System.err: at BottomNavigation.onLoaded(file:///node_modules/@nativescript/core/ui/bottom-navigation/bottom-navigation.js:289:13)
System.err: at (file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:312:89)
System.err: at ViewBase.callFunctionWithSuper(file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:305:8)
System.err: at ViewBase.callLoaded(file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:312:13)
System.err: at ViewBase.loadView(file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:440:17)
System.err: at (file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:234:18)
System.err: at ContentView.eachChildView(file:///node_modules/@nativescript/core/ui/content-view/content-view.js:70:12)
System.err: at PageBase.eachChildView(file:///node_modules/@nativescript/core/ui/page/page-common.js:126:39)
System.err: at ViewCommon.eachChild(file:///node_modules/@nativescript/core/ui/core/view/view-common.js:1010:13)
System.err: at ViewBase.onLoaded(file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:233:13)
System.err: at View.onLoaded(file:///node_modules/@nativescript/core/ui/core/view/view.js:247:34)
System.err: at Page.onLoaded(file:///node_modules/@nativescript/core/ui/page/page.js:43:34)
System.err: at (file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:312:89)
System.err: at ViewBase.callFunctionWithSuper(file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:305:8)
System.err: at ViewBase.callLoaded(file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:312:13)
System.err: at ViewBase.loadView(file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:440:17)
System.err: at (file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:234:18)
System.err: at FrameBase.eachChildView(file:///node_modules/@nativescript/core/ui/frame/frame-common.js:422:12)
System.err: at ViewCommon.eachChild(file:///node_modules/@nativescript/core/ui/core/view/view-common.js:1010:13)
System.err: at ViewBase.onLoaded(file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:233:13)
System.err: at View.onLoaded(file:///node_modules/@nativescript/core/ui/core/view/view.js:247:34)
System.err: at FrameBase.onLoaded(file:///node_modules/@nativescript/core/ui/frame/frame-common.js:87:34)
System.err: at (file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:312:89)
System.err: at ViewBase.callFunctionWithSuper(file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:305:8)
System.err: at ViewBase.callLoaded(file:///node_modules/@nativescript/core/ui/core/view-base/view-base.js:312:13)
System.err: at ActivityCallbacksImplementation.onStart(file:///node_modules/@nativescript/core/ui/frame/frame.js:872:21)
System.err: at NativeScriptActivity.onStart(file:///node_modules/@nativescript/core/ui/frame/activity.js:29:24)
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1160)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1138)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1134)
System.err: at com.tns.NativeScriptActivity.onStart(NativeScriptActivity.java:29)
System.err: at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1514)
System.err: at android.app.Activity.performStart(Activity.java:7838)
System.err: at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3398)
System.err: at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
System.err: at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
System.err: at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2109)
System.err: at android.os.Handler.dispatchMessage(Handler.java:107)
System.err: at android.os.Looper.loop(Looper.java:214)
System.err: at android.app.ActivityThread.main(ActivityThread.java:7682)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
System.err: Caused by: java.lang.IllegalArgumentException: No view found for id 0x2 (unknown) for fragment FragmentBase_vendor_15352_26_TabFragmentImplementation{54a9e51 #1 id=0x2 android:bottomnavigation:2:1}
System.err: at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1454)
System.err: at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
System.err: at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
System.err: at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802)
System.err: at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
System.err: at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
System.err: at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
System.err: at androidx.fragment.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2243)
System.err: at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:654)
System.err: ... 21 more
To Reproduce
- Download the sample-project zip.
- Unzip and install dependencies
- run:
tns debug android - Tap press “tap to login” and get navigated to the actual tab-navigation.
- Switch to any tab
- Change font-size either from Settings or use adb command: adb shell settings put system font_scale 1.5
- Go to desktop or another app and return
- Observe crash
Expected behavior Application should resize the text and not crash afterwards.
Sample project
Additional context
The bug was first issued to @nota/nativescript-accessibility-ext plugin but the author @m-abs of the plugin found logs pointing towards NativeScript upstream
https://github.com/Notalib/nativescript-accessibility-ext/issues/40
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (13 by maintainers)
@tsonevn You might need to leave the app and return to it a couple of times before the crash is triggered. For me it usually happens on the second return.
I’ve been able to reproduce it on two different OnePlus 7T Pro (one McLaren and one normal) running Android 10 (OxygenOS).
I couldn’t reproduce it on an Android emulator running Android 9.0.
@vakrilov I see that might explain, why it didn’t crash. The transaction didn’t do anything.
If I remove the call to
disposeCurrentFragment()fromonUnloaded()the crash also goes away.https://github.com/NativeScript/NativeScript/blob/master/nativescript-core/ui/frame/frame.android.ts#L252-L259
Sorry to nag, but it even happens with the example from this NativeScript blog post: https://www.nativescript.org/blog/tabs-and-bottomnavigation-nativescripts-two-new-components
I’ve more information.
You don’t need to change the font-size to trigger this crash.
I can do it on my Oneplus 7T Pro McL every time while in debug mode.
I tried adding a few debug statements to
bottom-navigation.android.js. The crash happens because return to the app triggersonLoaded()which callschangeTab(index)and finally callscommitCurrentTransaction().Just after leaving
onUnloaded()was called.I haven’t been able to get any further, I don’t fully understand view livecycles on Android.
@tsonevn My bad. i was using the android@6.2.0 when recreating the issue, just a typing error in my description. The example project has the correct platform aswell.
Let me get back to you after testing with other devices. Thanks!