[TIMOB-24756] Android: Ti.UI.ImageView with "images" property causes crash
| GitHub Issue | n/a |
| Type | Bug |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2017-06-05T22:47:06.000+0000 |
| Affected Version/s | Release 6.1.0 |
| Fix Version/s | Release 6.1.1 |
| Components | Android |
| Labels | merge-6.1.1, regression |
| Reporter | Joshua A. Ceaser |
| Assignee | Yordan Banev |
| Created | 2017-05-31T23:09:30.000+0000 |
| Updated | 2017-07-03T19:55:11.000+0000 |
Description
I'm getting this exception when running my application on Android with TI SDK 6.1.0. If the images property is set and start has been called, when the window closes you get the below errors. I have attached the controller, view, tss files
{quote}
[ERROR] : TiApplication: (Thread-926) [5221,5221] Sending event: exception on thread: Thread-926 msg:java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object org.appcelerator.titanium.proxy.TiViewProxy.getProperty(java.lang.String)' on a null object reference; Titanium 6.1.0,2017/05/26 15:24,undefined
[ERROR] : TiApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object org.appcelerator.titanium.proxy.TiViewProxy.getProperty(java.lang.String)' on a null object reference
[ERROR] : TiApplication: at ti.modules.titanium.ui.widget.TiUIImageView.getDuration(TiUIImageView.java:465)
[ERROR] : TiApplication: at ti.modules.titanium.ui.widget.TiUIImageView$Loader.run(TiUIImageView.java:406)
[ERROR] : TiApplication: at java.lang.Thread.run(Thread.java:818)
[DEBUG] : Window: Window is closed normally.
[ERROR] : TiApplication: (Timer-0) [51,5272] Sending event: exception on thread: Timer-0 msg:java.lang.NullPointerException: Attempt to invoke virtual method 'boolean org.appcelerator.titanium.proxy.TiViewProxy.fireEvent(java.lang.String, java.lang.Object, boolean)' on a null object reference; Titanium 6.1.0,2017/05/26 15:24,undefined
[ERROR] : TiApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean org.appcelerator.titanium.proxy.TiViewProxy.fireEvent(java.lang.String, java.lang.Object, boolean)' on a null object reference
[ERROR] : TiApplication: at org.appcelerator.titanium.view.TiUIView.fireEvent(TiUIView.java:1958)
[ERROR] : TiApplication: at org.appcelerator.titanium.view.TiUIView.fireEvent(TiUIView.java:1949)
[ERROR] : TiApplication: at ti.modules.titanium.ui.widget.TiUIImageView.fireChange(TiUIImageView.java:503)
[ERROR] : TiApplication: at ti.modules.titanium.ui.widget.TiUIImageView.access$1600(TiUIImageView.java:53)
[ERROR] : TiApplication: at ti.modules.titanium.ui.widget.TiUIImageView$Animator.run(TiUIImageView.java:553)
[ERROR] : TiApplication: at java.util.Timer$TimerImpl.run(Timer.java:284)
[INFO] : Process: Sending signal. PID: 16778 SIG: 9{quote}
Attachments
| File | Date | Size |
| blue.png | 2017-06-01T14:44:17.000+0000 | 341 |
| green.png | 2017-06-01T14:44:17.000+0000 | 342 |
| index.js | 2017-05-31T23:07:32.000+0000 | 89 |
| index.tss | 2017-05-31T23:07:32.000+0000 | 386 |
| index.xml | 2017-05-31T23:07:32.000+0000 | 115 |
| red.png | 2017-06-01T14:44:17.000+0000 | 326 |
Some issues that I can see with this test-case: * You are closing the root-window of the application, I guess the issue itself was happening in a sub-window? * The images have spaces in their filenames * Does this only happen on 6.1.0.GA and did it work in 6.0.x? It crashes in [this line](https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIImageView.java#L465) and suspects that the proxy is already null when accessing. Here is an isolated test-case that may reproduce the issue (remember to place the referenced images in your resources directory):
var window = Ti.UI.createWindow({ backgroundColor: 'white' }); var btn = Ti.UI.createButton({ title: 'Open Sub-Window' }); btn.addEventListener('click', function() { var window2 = Ti.UI.createWindow({ backgroundColor: 'green' }); var background = Ti.UI.createView({ left: 0, right: 0, top: 0, bottom: 0, backgroundColor: 'black', opacity: '.6' }); var loading = Ti.UI.createImageView({ top: 140, duration: 70, images: ['apple.png', 'orange.png', 'pinapple.png'] }); background.add(loading); window2.add(background); loading.start(); setTimeout(function() { window2.close(); }, 5000); window2.open(); }); window.add(btn); window.open();Hans, to answer your questions: * In the application where I observed the issue I open a new window and close the previous one which has this type of image view. * Even if I change the image names, the result is the same * This only happens with 6.1.0.GA if I change back to 6.0.4 it works fine The test case you posted does recreate the issue.
master: https://github.com/appcelerator/titanium_mobile/pull/9103
6_1_X: https://github.com/appcelerator/titanium_mobile/pull/9109
Verified fix in SDK version 6.1.1.v20170605155640 and 6.2.0.v20170605134755. Test and other information can be found at: Master: https://github.com/appcelerator/titanium_mobile/pull/9103 6_1_X: https://github.com/appcelerator/titanium_mobile/pull/9109
This has created a regression issue. Adding
handleStop()to the release event is causing aNullPointerExceptionwith theorg.appcelerator.titanium.proxy.TiViewProxy.fireEventbeing called on a null reference. For example when anImageViewis being used in aScrollableView.[~dbankier] Could you provide a test case that reproduces the issue?
Sure:
var win = Ti.UI.createWindow(); var view1 = Ti.UI.createWindow({ backgroundColor:'#123' }); var view2 = Ti.UI.createWindow(); var imageView = Ti.UI.createImageView({ image:'appicon.png' }) view2.add(imageView); var view3 = Ti.UI.createWindow({ backgroundColor:'#48b' }); var view4 = Ti.UI.createWindow(); var row = Ti.UI.createTableViewRow(); var image = Ti.UI.createImageView({ image:'appicon.png' }) row.add(image); var table = Ti.UI.createTableView({data: [row]}); view4.add(table) var view5 = Ti.UI.createWindow({ backgroundColor:'#48b' }); var scrollableView = Ti.UI.createScrollableView({ views:[view1,view2,view3,view4, view5], showPagingControl:true }); var currentPage = 0; setInterval(function() { currentPage++ scrollableView.currentPage = currentPage % 5 },1000) win.add(scrollableView); win.open();