Repository navigation
Changing font-size / display-size in combination with BottomNavigation causes crash #8104
Copy link
Copy link
Closed
Labels
Description
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 moreTo 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
Notalib/nativescript-accessibility-ext#40
Activity
tsonevn commentedon Nov 18, 2019
Hi @oslc15,
I tested the provided project while following the described steps, but I was unable to recreate the crash. I checked the app on a Samsung device with Android 9 and NExus 5x with Android 8.1. On that matter, I noticed that you are using an old Android runtime version. Can you try updating it to the latest version (v 6.2) while following the steps below:
tns platform remove androidtns platform add [email protected]Then check if the problem still persists.
oslc15 commentedon Nov 18, 2019
@tsonevn My bad. i was using the [email protected] 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!
m-abs commentedon Nov 18, 2019
@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.
m-abs commentedon Nov 18, 2019
I couldn't reproduce it in an Android 10 emulator either.
m-abs commentedon Nov 20, 2019
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 triggers
onLoaded()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.
m-abs commentedon Nov 28, 2019
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
m-abs commentedon Dec 4, 2019
I think, I've found the cause of the problem.
Be enabling tracing, we could see a curious difference between the Android 8 device and the Android 10 device.
On the Android 8 device we could see a
Fade@adsadstarting and ending when the app was suspended, but on the Android 10 device we could only see aFade@csdwestarting but not ending.When the app is suspended, Frame calls
disposeCurrentFragment()that does this:transaction.commitNowAllowingStateLoss()If I change that to:
transaction.commitNowAllowingStateLoss()The crash doesn't happen anymore.
I've created a PR switching the two lines of code that fixed the problem for me.
vakrilov commentedon Dec 5, 2019
Hey @m-abs
I we have been investigating a related crash (reported in #8037). There is a PR in place that might fix this issue as well -> #8165. Are you willing to give it a try?
m-abs commentedon Dec 5, 2019
Hey @vakrilov,
I assume you meant #8166 ;)
I've just tested it on the example project and it still crashed on my Oneplus 7T pro.
It doesn't if I flip these two lines in the
disposeCurrentFragment()-function:From:
To:
vakrilov commentedon Dec 6, 2019
Hey @m-abs
Calling
remove()after the committing the transaction is the same as not calling it at all, as theremoveoperation will never be committed.m-abs commentedon Dec 8, 2019
@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
m-abs commentedon Dec 10, 2019
This turned out to be a bad idea. It caused tab content to be half transparent when switching between the tabs.
m-abs commentedon Dec 11, 2019
The crash is consistent on my Oneplus 7T pro with Android 10, but not on my emulator with Android 10.
I've noticed an interesting difference between the two.
Log from the emulator:
android-10-emulator.log
Log from the Oneplus 7T pro device:
android-10-device.log
On the emulator just after leaving the app end it is suspended, a transition is started (logged from: TransitionListenerImpl.onTransitionStart()) and ended (logged from: TransitionListenerImpl.onTransitionEnd()) immediately after being started.
But on the device, the transition is started, but not ended.
I suspect this has something to do with the app crashing on resume, but I don't understand why the transition doesn't end.
NickSch1 commentedon Dec 13, 2019
I'm experiencing crashes with the same stacktrace.
The crashes happen immediately when the app gets suspended. We're using the BottomNavigation component in a NativeScript Angular project.
They happen on my Android 10 Emulator but also on my Samsung S8 with Android 9.
When I find some time I'll try to look into it aswell but my experience with native android development is pretty limited.
Versions:
m-abs commentedon Jan 15, 2020
@vakrilov I think this issue should be closed.