Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4889] Android: View.backgroundImage With 24-bit PNG Crashes App with 1.7.2

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionDuplicate
Resolution Date2013-03-06T21:25:32.000+0000
Affected Version/sRelease 1.7.2, Release 2.0.2
Fix Version/sn/a
ComponentsAndroid
Labelsapi
ReporterDawson Toth
AssigneeIngo Muschenetz
Created2011-08-04T09:48:56.000+0000
Updated2017-03-22T18:33:44.000+0000

Description

Problem

Using a 24-bit PNG as the backgroundImage of a view causes the app to crash on 1.7.2 on device.

Reproduction

1. Download the following image to your resources directory: http://tothsolutions.com/logostrip.png (note: if you specify the remote image, the app will NOT crash. But if you save it locally and use that image, it will crash.) 2. Drop the following in an app.js, and run it using 1.7.2. The app will crash.
var win = Ti.UI.createWindow();
win.add(Ti.UI.createView({
    top: 0, left: 0, right: 0, height: 33,
    backgroundImage: 'logostrip.png'
}));
win.open();

Error Log

08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597): (main) [218,608] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.navtrak.navtrakmobile/com.navtrak.navtrakmobile.NavtrakActivity}: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0; Titanium 1.7.2,2011/07/21 09:36,97c3689
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.navtrak.navtrakmobile/com.navtrak.navtrakmobile.NavtrakActivity}: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2757)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2775)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at android.app.ActivityThread.access$2500(ActivityThread.java:130)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2121)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at android.os.Looper.loop(Looper.java:143)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at android.app.ActivityThread.main(ActivityThread.java:4773)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at java.lang.reflect.Method.invokeNative(Native Method)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at java.lang.reflect.Method.invoke(Method.java:521)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at dalvik.system.NativeStart.main(Native Method)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at java.util.ArrayList.get(ArrayList.java:311)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.util.TiNinePatchHelper.createChunk(TiNinePatchHelper.java:187)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.util.TiNinePatchHelper.process(TiNinePatchHelper.java:50)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.util.TiFileHelper.loadDrawable(TiFileHelper.java:320)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.util.TiFileHelper.loadDrawable(TiFileHelper.java:260)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.util.TiUIHelper.buildBackgroundDrawable(TiUIHelper.java:447)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.view.TiUIView.handleBackgroundImage(TiUIView.java:655)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.view.TiUIView.processProperties(TiUIView.java:453)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at ti.modules.titanium.ui.widget.TiView.processProperties(TiView.java:38)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:519)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:378)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:370)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.proxy.TiViewProxy.getView(TiViewProxy.java:356)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:434)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:196)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:100)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:86)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at android.os.Handler.dispatchMessage(Handler.java:95)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.TiMessageQueue.dispatchMessage(TiMessageQueue.java:320)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.TiMessageQueue.dispatchPendingMessages(TiMessageQueue.java:304)
08-04 11:33:29.649: ERROR/TiUncaughtHandler(11597):     at org.appcelerator.titanium.TiMessageQueue$2.getResult(TiMessageQueue.java:172)

Comments

  1. Justin Toth 2011-08-05

    For most Android devices, changing the PNG-24 to PNG-32 or to JPG resolves the issue. However, one user with a Droid X running Android 2.3.3 still receives the error below even with the image converted to a JPG. So this seems to be a larger issue than just with PNG-24's.
  2. Sungil Kim 2012-06-07

    It seems like the picture with a black border is considered as 9-patch image... Still has this problem at 2.0.2GA.
  3. Daniel Guy 2013-01-09

    This appears to still happen in 3.0. Any timing on a fix?
  4. Daniel Guy 2013-03-06

    I see that this was closed as a duplicate issue. Can you point me to the issue that we should be tracking in its place?
  5. Dawson Toth 2013-03-06

    [TIMOB-12961], which is a private ticket.
  6. Daniel Guy 2013-03-06

    Is there any way that ticket can be made public, or at least any way we can be notified when this is scheduled to be fixed and when it actually is fixed?
  7. Ping Wang 2013-03-06

    PR https://github.com/appcelerator/titanium_mobile/pull/3939
  8. Dawson Toth 2013-03-06

    One of us will post here when that ticket is resolved. There's a PR open for it already. https://github.com/appcelerator/titanium_mobile/pull/3939
  9. Dawson Toth 2013-03-13

    The ticket was resolved and verified.
  10. Daniel Guy 2013-03-13

    Thanks Dawson. Will the fix be in 3.1 or a different sdk version?
  11. Dawson Toth 2013-03-13

    3.1.0.
  12. Lee Morris 2017-03-22

    Closing ticket as duplicate.

JSON Source