Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24605] Android: Setting "backgroundImage" to a web URL causes a crash if JS is running on the UI thread

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-08-24T01:43:40.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.5.0
ComponentsAndroid
Labelsandroid, backgroundImage, defaultImage, url, view
ReporterILAY SENER
AssigneeJoshua Quick
Created2017-04-20T09:40:20.000+0000
Updated2018-08-24T01:43:44.000+0000

Description

*Summary:* Setting Android 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);

Comments

  1. Joshua Quick 2018-08-01

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10222
  2. Samir Mohammed 2018-08-14

    *Closing ticket.* Verified improvement in SDK version: 7.4.0.v20180810061237. Application no longer crashes when setting a backgroundimage 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*
       APPC Studio: 5.0.0.201712081732
       APPC CLI: 7.0.4
       Pixel XL (8.1)
       Operating System Name: Mac OS High Sierra
       Operating System Version: 10.13
       Node.js Version: 8.9.1
       Xcode 9.2
       

JSON Source