[TIMOB-16351] Android: addEventListener via call()/apply() fails with exception
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2018-01-03T02:39:51.000+0000 |
Affected Version/s | Release 3.2.0 |
Fix Version/s | n/a |
Components | Android |
Labels | andoid |
Reporter | Manojkumar Murugesan |
Assignee | Maggie Chen |
Created | 2014-01-29T11:47:38.000+0000 |
Updated | 2018-01-03T02:39:51.000+0000 |
Description
I'm using this widget https://github.com/hoyo/net.hoyohoyo.iconiclabel where they are getting reference of (https://github.com/hoyo/net.hoyohoyo.iconiclabel/blob/master/app/widgets/net.hoyohoyo.iconiclabel/controllers/widget.js) some list of functions / properties and export them. When I use addEventListener it crashes on Android but works fine on iOS.
This is similar to TIMOB-9560 but on Android.
[~mano_mykingdom] I used the addEventListener method on Android Galaxy S3 and its not crashing. I am using the following test scenario's.
If you are doing something different, please attach a simple and runnable test case so that we can reproduce the issue.
I'm using like this. It crashes on Android but fine with iOS.
Moving this ticket to engineering as I can reproduce the issue with the provided code. Note that this is a valid scenario as per ticket TIMOB-9560 and it works fine for iOS platform.
Not only addEventListener but all the methods it seems. I tried the below one it works on iOS and fails on Android.
There is a reason for this kind of use case, for example when I have a label / button in a widget and want to access the methods of that object from a controller where it is included. Have a look here https://github.com/hoyo/net.hoyohoyo.iconiclabel/blob/master/app/widgets/net.hoyohoyo.iconiclabel/controllers/widget.js at line no. 320
I don't think this is a bug. Assigning lbl.setVisible to a variable will detach the method from the lbl and needs to be bound again before calling it. Something like var visible = lbl.setVisible; var boundVisible = visible.bind(lbl); boundVisible(true);
3.4.0 is moved forward, and 3.5.0 is taking its place in the calendar.
Issue reproduces Titanium SDK version 3.4.0 master, 3.2.0.GA Titanium Studio, build: 3.3.0.201407100905 Titanium Command-Line Interface CLI version 3.3.0, Android device : Motorola Moto G, Android version : 4.4.4 iOS simulator : iPhone Retina (3.5-inch), iOS 7.0.3
Unable to reproduce with the code as follows. The exception can be avoided through the following code:
or