[TIMOB-27779] Android: Setting "labels" via TabbedBar "click" event hangs app
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-08-11T15:04:56.000+0000 |
Affected Version/s | Release 8.0.0 |
Fix Version/s | Release 9.1.0 |
Components | Android |
Labels | android, hang, tabbedbar |
Reporter | Tony Lau |
Assignee | Riduanul Islam |
Created | 2019-12-10T06:32:33.000+0000 |
Updated | 2020-08-11T15:04:56.000+0000 |
Description
*Steps to reproduce:*
Build and run the below code on Android.
Tap on one of the tabs.
Notice that the app hangs.
var window = Ti.UI.createWindow();
var tabbedBar = Ti.UI.createTabbedBar();
tabbedBar.labels = ["One", "Two", "Three"];
tabbedBar.addEventListener("click", function() {
console.log(new Date() + " tbrSortTLby Click event triggerred");
tabbedBar.labels = ['Three', 'Four', 'Five'];
});
window.add(tabbedBar);
window.open();
*Cause:*
Setting the "labels" property causes the "click" event to be fired. So, setting "labels" within a "click" event listener will cause infinite recursion to occur which will eventually cause a crash.
*Work-Around:*
Defer setting the "labels" property via setTimeout()
within the "click" listener.
Attachments
File | Date | Size |
---|---|---|
AndroidSandBox.zip | 2019-12-28T09:22:31.000+0000 | 8669614 |
AndroidTabbedBarTrace.log | 2019-12-28T09:20:52.000+0000 | 334019 |
Trace log pic.png | 2019-12-24T15:39:48.000+0000 | 45075 |
Hi, I've tested this issue in 3 different pattern but failed to reproduce this. Can you try this below code and help us to reproduce this:
If you have another reproducible steps, let us know the full steps with code, also provide us the full log from command line. My Testing environments are following:
The crash occur after the Window is opened with the tabbed bar displayed, and then try to change the labels in code. tabbedBar.labels = ["Four", "Five", "Six"];
Hi Tony Lau, Can you share complete trace log with us? See this image below for details information: !Trace log pic.png|thumbnail! Thanks.
I created a new project AndroidSandBox and able to reproduce the repeat "click" issue. index.html
Click on any of the labels. e.g "One", the labels cahnged to "Four", "Five" and "Six" as expected but the trace log showed the click event is continuously triggered. Detail trace log and project code attached. [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [INFO] : chatty: uid=10088(u0_a88) com.mysandbox.android identical 6 lines [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [INFO] : zygote: Do partial code cache collection, code=29KB, data=22KB [INFO] : zygote: After code cache collection, code=29KB, data=22KB [INFO] : zygote: Increasing code cache capacity to 128KB [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [INFO] : chatty: uid=10088(u0_a88) com.mysandbox.android identical 1 line [DEBUG] : Sat Dec 28 2019 01:01:19 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:20 GMT-0800 (PST) tbrSortTLby Click event triggerred [INFO] : chatty: uid=10088(u0_a88) com.mysandbox.android identical 7 lines [DEBUG] : Sat Dec 28 2019 01:01:20 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:20 GMT-0800 (PST) tbrSortTLby Click event triggerred [INFO] : chatty: uid=10088(u0_a88) com.mysandbox.android identical 6 lines [DEBUG] : Sat Dec 28 2019 01:01:20 GMT-0800 (PST) tbrSortTLby Click event triggerred [INFO] : zygote: Do partial code cache collection, code=61KB, data=42KB [INFO] : zygote: After code cache collection, code=61KB, data=42KB [INFO] : zygote: Increasing code cache capacity to 256KB [DEBUG] : Sat Dec 28 2019 01:01:20 GMT-0800 (PST) tbrSortTLby Click event triggerred [INFO] : chatty: uid=10088(u0_a88) com.mysandbox.android identical 35 lines [DEBUG] : Sat Dec 28 2019 01:01:20 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:21 GMT-0800 (PST) tbrSortTLby Click event triggerred [INFO] : chatty: uid=10088(u0_a88) com.mysandbox.android identical 26 lines [DEBUG] : Sat Dec 28 2019 01:01:21 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:21 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:21 GMT-0800 (PST) tbrSortTLby Click event triggerred [INFO] : chatty: uid=10088(u0_a88) com.mysandbox.android identical 25 lines [DEBUG] : Sat Dec 28 2019 01:01:21 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:22 GMT-0800 (PST) tbrSortTLby Click event triggerred [INFO] : chatty: uid=10088(u0_a88) com.mysandbox.android identical 43 lines [DEBUG] : Sat Dec 28 2019 01:01:22 GMT-0800 (PST) tbrSortTLby Click event triggerred [DEBUG] : Sat Dec 28 2019 01:01:22 GMT-0800 (PST) tbrSortTLby Click event triggerred
Need more info? Hope this can be fixed in SDK 9
Since you are setting new labels inside the click event I think it will trigger the event again because it is selecting the first new value. Chaging it to this:
will remove the event listener, change the labels and add it again. No loop. Also added a "changed" variable so you will be able to select one of the new values inside the new labels. When the bar is created it will first set the values and then attach the select-listener: https://github.com/appcelerator/titanium_mobile/blob/0558c28b54dfb195d7a5c22851060e416e9811f8/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUITabbedBar.java#L86-L87 when you change the values now the listener is catching the select event and that will trigger the click: https://github.com/appcelerator/titanium_mobile/blob/0558c28b54dfb195d7a5c22851060e416e9811f8/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUITabbedBar.java#L325-L345 So you have to remove the click event before changing the value or you could do that inside the SDK when setting new labels.
PR: https://github.com/appcelerator/titanium_mobile/pull/11495 classic test code:
FR passed, waiting on Jenkins build.
Looks like this will need a back port for 9_1_X now.
PR (9.1.x): https://github.com/appcelerator/titanium_mobile/pull/11838
merged PRs to master and 9_1_X. Manually cherry-picked to 9_3_X
*Closing ticket*. Bug Fixed in SDK version
9.1.0.v20200810120239
,9.2.0.v20200810085310
and9.3.0.v20200810090511
. *Test and other information can be found at:* https://github.com/appcelerator/titanium_mobile/pull/11495 https://github.com/appcelerator/titanium_mobile/pull/11838