Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28418] Android: Setting tab property after creation and before open causes crash as of 10.0.0

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2021-04-13T18:47:22.000+0000
Affected Version/sRelease 10.0.0
Fix Version/sRelease 10.0.0
ComponentsAndroid
LabelsTabGroup, android, regression, tab
ReporterJoshua Quick
AssigneeJoshua Quick
Created2021-04-12T22:14:10.000+0000
Updated2021-04-13T18:47:22.000+0000

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:*

Build and run [^TabGroupChangeBeforeOpenTest.js] on Android.

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

FileDateSize
TabGroupChangeBeforeOpenTest.js2021-04-12T22:07:51.000+0000631

Comments

  1. Joshua Quick 2021-04-13

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/12717
  2. Samir Mohammed 2021-04-13

    FR Passed, waiting on Jenkins build
  3. Christopher Williams 2021-04-13

    merged to master and 10_0_X branches for 10.0.0 target

JSON Source