Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-28418

Android: Setting tab property after creation and before open causes crash as of 10.0.0

    Details

    • Story Points:
      3
    • Sprint:
      2021 Sprint 8

      Description

      Summary:
      As of Titanium 10.0.0, setting a tab property such as "title", "icon", "badge", etc. will cause a crash if set after TabGroup creation and before the TabGroup's open event has been fired.

      This bug was caught before release.

      Steps to reproduce:

      1. Build and run TabGroupChangeBeforeOpenTest.js on Android.
      2. Notice it crashes on app startup.

      Result:

      [ERROR] TiExceptionHandler: tabGroup.tabs[0].title="Tab 1",
      [ERROR] TiExceptionHandler:                       ^
      [ERROR] TiExceptionHandler: Error: Windows are created during open
      [ERROR] TiExceptionHandler:     at /TabGroupChangeBeforeOpenTest.js:16:23
      [ERROR] TiExceptionHandler:     at Module._runScript (ti:/kroll.js:1351:15)
      [ERROR] TiExceptionHandler:     at Module.load (ti:/kroll.js:831:13)
      [ERROR] TiExceptionHandler:     at Module.loadJavascriptText (ti:/kroll.js:1197:15)
      [ERROR] TiExceptionHandler:     at Module.loadAsFile (ti:/kroll.js:1249:22)
      [ERROR] TiExceptionHandler:     at Module.loadAsFileOrDirectory (ti:/kroll.js:1168:26)
      [ERROR] TiExceptionHandler:     at Module.require (ti:/kroll.js:1037:24)
      [ERROR] TiExceptionHandler:     at Module.global.Module.require (<embedded>:5086:32)
      [ERROR] TiExceptionHandler:     at require (ti:/kroll.js:1315:22)
      [ERROR] TiExceptionHandler:     at /app.js:293:1
      [ERROR] TiExceptionHandler:
      [ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiWindowProxy.createView(TiWindowProxy.java:100)
      [ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:467)
      [ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:434)
      [ERROR] TiExceptionHandler:     ti.modules.titanium.ui.TabProxy.onPropertyChanged(TabProxy.java:248)
      [ERROR] TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
      [ERROR] TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:172)
      [ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiApplication.launch(TiApplication.java:854)
      [ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiLaunchActivity.loadScript(TiLaunchActivity.java:96)
      [ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiRootActivity.loadScript(TiRootActivity.java:497)
      [ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiLaunchActivity.onResume(TiLaunchActivity.java:177)
      [ERROR] V8Exception: Exception occurred at /TabGroupChangeBeforeOpenTest.js:16: Uncaught Error: Windows are created during open
      

      Reason:
      Our Java TabGroupProxy class does not support the createView(). Calling it will cause the above exception to be thrown via its TiWindowProxy class here...
      https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/proxy/TiWindowProxy.java#L100

      The createView() method is getting called because our TabProxy.onPropertyChanged() method calls getOrCreateView() methods (see link below). I'm not sure why it didn't crash before, but the correct solution is to call tabGroupProxy.peekView() and if it returns null then return out.
      https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/TabProxy.java#L236-L263

      Work-Around:
      Set all tab properties upon creation or after the "open" event has fired.

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              jquick Joshua Quick
              Reviewer:
              Gary Mathews
              Tester:
              Samir Mohammed
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration