Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28386] Android: App crashes when changing to dark mode

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionDone
Resolution Date2021-04-08T00:50:21.000+0000
Affected Version/sRelease 10.0.0
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterHans Knöchel
AssigneeJoshua Quick
Created2021-03-12T12:22:48.000+0000
Updated2021-04-08T00:50:21.000+0000

Description

On Android with SDK 10, the app crashes when toggling light- and dark-mode:
[ERROR] TiExceptionHandler: (main) [68,139775] Attempt to invoke virtual method 'boolean org.appcelerator.kroll.KrollDict.containsKey(java.lang.Object)' on a null object reference
[ERROR] TiExceptionHandler:
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.view.TiUIView.processProperties(TiUIView.java:954)
[ERROR] TiExceptionHandler:     ti.pageindicator.PageIndicatorView.processProperties(PageIndicatorView.kt:31)
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1312)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:486)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:476)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:437)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:493)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:476)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:437)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:493)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:476)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:437)
[ERROR] TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUITab.getContentView(TiUITab.java:52)
[ERROR] TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTabGroup$TabFragment.onCreateView(TiUIAbstractTabGroup.java:613)
[ERROR] TiExceptionHandler:     androidx.fragment.app.Fragment.performCreateView(Fragment.java:2950)
[ERROR] TiExceptionHandler:     androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:515)
[ERROR] TiExceptionHandler:     androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
[ERROR] TiExceptionHandler:     androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177)
[ERROR] TiExceptionHandler:     androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2088)
[ERROR] TiExceptionHandler:     androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1959)
[ERROR] TiExceptionHandler:     androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:311)
[ERROR] TiExceptionHandler:     androidx.fragment.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:249)
[ERROR] TiExceptionHandler:     androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1244)
[ERROR] TiExceptionHandler:     androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
[ERROR] TiExceptionHandler:     androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1622)
[ERROR] TiExceptionHandler:     android.view.View.measure(View.java:25466)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:742)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:575)
[ERROR] TiExceptionHandler:     android.view.View.measure(View.java:25466)
[ERROR] TiExceptionHandler:     android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
[ERROR] TiExceptionHandler:     android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
[ERROR] TiExceptionHandler:     androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:146)
[ERROR] TiExceptionHandler:     android.view.View.measure(View.java:25466)
[ERROR] TiExceptionHandler:     android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
[ERROR] TiExceptionHandler:     androidx.appcompat.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:490)
[ERROR] TiExceptionHandler:     android.view.View.measure(View.java:25466)
[ERROR] TiExceptionHandler:     android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
[ERROR] TiExceptionHandler:     android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
[ERROR] TiExceptionHandler:     android.view.View.measure(View.java:25466)
[ERROR] TiExceptionHandler:     android.widget.LinearLayout.measureVertical(LinearLayout.java:995)
[ERROR] TiExceptionHandler:     android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
[ERROR] TiExceptionHandler:     android.view.View.measure(View.java:25466)
[ERROR] TiExceptionHandler:     android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
[ERROR] TiExceptionHandler:     android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
[ERROR] TiExceptionHandler:     com.android.internal.policy.DecorView.onMeasure(DecorView.java:747)
[ERROR] TiExceptionHandler:     android.view.View.measure(View.java:25466)
[ERROR] TiExceptionHandler:     android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3402)
[ERROR] TiExceptionHandler:     android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2246)
[ERROR] TiExceptionHandler:     android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2504)
[ERROR] TiExceptionHandler:     android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1948)
[ERROR] TiExceptionHandler:     android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8177)
[ERROR] TiExceptionHandler:     android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
[ERROR] TiExceptionHandler:     android.view.Choreographer.doCallbacks(Choreographer.java:796)
[ERROR] TiExceptionHandler:     android.view.Choreographer.doFrame(Choreographer.java:731)
[ERROR] TiExceptionHandler:     android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
[ERROR] TiExceptionHandler:     android.os.Handler.handleCallback(Handler.java:938)
[ERROR] TiExceptionHandler:     android.os.Handler.dispatchMessage(Handler.java:99)
[ERROR] TiExceptionHandler:     android.os.Looper.loop(Looper.java:223)
[ERROR] TiExceptionHandler:     android.app.ActivityThread.main(ActivityThread.java:7660)
[ERROR] TiExceptionHandler:     java.lang.reflect.Method.invoke(Native Method)
[ERROR] TiExceptionHandler:     com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
[ERROR] TiExceptionHandler:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
First, we thought it's our custom module (ti.pageindicator), but the crash occurs in the proxy handler. All we do is:
    override fun processProperties(d: KrollDict?) {
        super.processProperties(d) // <-- This is called and then crahses in the super-function

        if (d == null) {
            return
        }

        for (key in d.keys) {
            handleProperty(key, d[key])
        }
    }

Comments

  1. Joshua Quick 2021-03-13

    [~hknoechel], I added a bunch of null reference guards to our proxy code in the below PR. https://github.com/appcelerator/titanium_mobile/pull/12537 However, the real issue is that the "ti.pageindicator" module's proxy object is being "released" when it shouldn't. So, even with my above null guards, odds are this proxy object will stop functioning after changing themes. The root issue is that the module's proxy objects are wrongly being released when the activity is being recreated, but I'm not seeing this issue anywhere else (such as MapView in "ti.map"). I can't get to the root of the issue without seeing the module's code.
  2. Joshua Quick 2021-04-08

    Closing since we've added null-guards to Titanium 10.0.0 and 3rd party module affected was changed to avoid issue.

JSON Source