Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13688] Android: android.graphics.Bitmap.getByteCount Crash on HoneyComb (TiImageLruCache.sizeOf)

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2013-04-30T16:58:58.000+0000
Affected Version/sRelease 3.1.0
Fix Version/s2013 Sprint 09 Core, 2013 Sprint 09, Release 3.1.1, Release 3.2.0
ComponentsAndroid
Labelsn/a
ReporterBrian Lonsdorf
AssigneeMatt Langston
Created2013-04-26T17:44:49.000+0000
Updated2013-11-20T22:33:58.000+0000

Description

App crashes when we're loading images only on Honeycomb. Works on Android 2.3.3 and 4.0. Checked the android docs with Matt and found getByteCount was introduced in api level 12. This link seems to indicated that we're checking on >= when it should be > since the API_LEVEL_HONEYCOMB is defined as 11. https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/util/TiImageLruCache.java Stack Trace: tStatusBar( 188): lights on I/ActivityManager( 131): Starting: Intent { cmp=com.playdom.mobile.gardensoftime/org.appcelerator.titanium.TiActivity (has extras) } from pid 556 W/InputManagerService( 131): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@40ac4738 (uid=10024 pid=257) I/WindowManager( 131): Setting rotation to 2, animFlags=0 D/Tablet/NotificationPanel( 188): notificationCount=1 D/Vold ( 81): USB connected E/AndroidRuntime( 556): FATAL EXCEPTION: main E/AndroidRuntime( 556): java.lang.NoSuchMethodError: android.graphics.Bitmap.getByteCount E/AndroidRuntime( 556): at org.appcelerator.titanium.util.TiImageLruCache.sizeOf(TiImageLruCache.java:45) E/AndroidRuntime( 556): at org.appcelerator.titanium.util.TiImageLruCache.sizeOf(TiImageLruCache.java:14) E/AndroidRuntime( 556): at android.support.v4.util.LruCache.safeSizeOf(LruCache.java:230) E/AndroidRuntime( 556): at android.support.v4.util.LruCache.put(LruCache.java:123) E/AndroidRuntime( 556): at ti.modules.titanium.ui.widget.TiUIImageView$2.loadImageFinished(TiUIImageView.java:134) E/AndroidRuntime( 556): at org.appcelerator.titanium.util.TiLoadImageManager.handleLoadImageMessage(TiLoadImageManager.java:90) E/AndroidRuntime( 556): at org.appcelerator.titanium.util.TiLoadImageManager.handleMessage(TiLoadImageManager.java:107) E/AndroidRuntime( 556): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime( 556): at android.os.Looper.loop(Looper.java:126) E/AndroidRuntime( 556): at android.app.ActivityThread.main(ActivityThread.java:3997) E/AndroidRuntime( 556): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 556): at java.lang.reflect.Method.invoke(Method.java:491) E/AndroidRuntime( 556): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) E/AndroidRuntime( 556): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) E/AndroidRuntime( 556): at dalvik.system.NativeStart.main(Native Method) W/ActivityManager( 131): Force finishing activity com.playdom.mobile.gardensoftime/org.appcelerator.titanium.TiActivity W/ActivityManager( 131): Activity pause timeout for ActivityRecord{40da9fb8 com.playdom.mobile.gardensoftime/org.appcelerator.titanium.TiActivity} D/Vold ( 81): USB disconnected D/Tablet/NotificationPanel( 188): notificationCount=0 D/Tablet/NotificationPanel( 188): notificationCount=1 D/Vold ( 81): USB connected W/ActivityManager( 131): Launch timeout has expired, giving up wake lock! W/ActivityManager( 131): Activity idle timeout for ActivityRecord{40ce8360 com.playdom.mobile.gardensoftime/.GardensActivity} W/ActivityManager( 131): Activity destroy timeout for ActivityRecord{40da9fb8 com.playdom.mobile.gardensoftime/org.appcelerator.titanium.TiActivity} I/WindowManager( 131): WIN DEATH: Window{40daab20 com.playdom.mobile.gardensoftime/com.playdom.mobile.gardensoftime.GardensActivity paused=false} I/ActivityManager( 131): Process com.playdom.mobile.gardensoftime (pid 556) has died.

Comments

  1. Matt Langston 2013-04-26

    PR: https://github.com/appcelerator/titanium_mobile/pull/4217
  2. Matt Langston 2013-05-17

    Backport PR for 3_1_X: https://github.com/appcelerator/titanium_mobile/pull/4289
  3. Ping Wang 2013-05-17

    Test steps: Please check the [android doc](http://developer.android.com/reference/android/graphics/Bitmap.html#getByteCount()). The getByteCount() function is for API 12+. The fix makes our code match the doc.
  4. Eric Merriman 2013-05-30

    @Ping. Not sure if there is enough info there to do anything with.
  5. Matt Langston 2013-05-30

    Eric, there is no coded "test case" for this bug. The fix was making our implementation consistent with the Google's documentation of the method, which fixed a bug for Lanica's "Gardens of Time" app.
  6. Eric Merriman 2013-05-31

    @Matt, understood. Although I can verify the code change, I do not have a test case for this.
  7. Lokesh Choudhary 2013-11-20

    Verified the code change as described in the ticket as there is no coded test to verify. Closing. Environment: Appcel Studio : 3.2.0.201311200357 Ti SDK : 3.2.0.v20131119142443 Mac OSX : 10.8.5 Alloy : 1.3.0 CLI - 3.2.0-alpha Device: Samsung Galaxy S4 running android 4.2.2

JSON Source