[TIMOB-24605] Android: Setting "backgroundImage" to a web URL causes a crash if JS is running on the UI thread
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-08-24T01:43:40.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.5.0 |
Components | Android |
Labels | android, backgroundImage, defaultImage, url, view |
Reporter | ILAY SENER |
Assignee | Joshua Quick |
Created | 2017-04-20T09:40:20.000+0000 |
Updated | 2018-08-24T01:43:44.000+0000 |
Description
*Summary:*
Setting Android Set "tiapp.xml" file property "run-on-main-thread" to
View
property "backgroundImage" to a URL will cause a crash if "tiapp.xml" property "run-on-main-thread" is set to true
.
_(This also happens with ImageView
"defaultImage" property as well.)_
*Steps to reproduce:*
Uninstall the app from the device if already installed. (Will delete cached web responses.)
Make sure the Android device has Internet access.
Set "tiapp.xml" file property "run-on-main-thread" to true
.
Build and run the below code.
Notice that the app crashes/hangs on startup.
tiapp.xml
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
<property name="run-on-main-thread" type="bool">true</property>
</ti:app>
app.js
var window = Ti.UI.createWindow();
window.add(Ti.UI.createView({
backgroundImage: "http://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Portrait_1.jpg",
}));
window.open();
----
*Original Post:*
I am unable to set background image for an imageView using an external URL. It crashes the app, but only if ran via main thread.
*index.xml*
<Alloy>
<Window>
<ImageView id="imageView" />
</Window>
</Alloy>
*index.js*
var b = "http://www.onlineinstruments.co.in/assets/images/Online%20Logo_PNG.png";
$.imageView.setBackgroundImage(b);
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10222
*Closing ticket.* Verified improvement in SDK version:
7.4.0.v20180810061237
. Application no longer crashes when setting abackgroundimage
to a web URL when running on main thread. *FR Passed (Test Steps):*Created a new application using Titanium
Set the "tiapp.xml" file property "run-on-main-thread" to true.
Built and ran the first test case in https://github.com/appcelerator/titanium_mobile/pull/10222
Image was displayed successfully without any issues
Uninstalled the created application
Changed the code to match the second test case found in https://github.com/appcelerator/titanium_mobile/pull/10222
Built and ran the second test case
Image was displayed "upright" successfully and the application did not crash
*Test Environment*