Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8545] Android: when imageview width or height are set to 0 or invalid, no bitmap scaling occurs

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2017-06-12T19:41:24.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterOpie Cyrus
AssigneeEric Merriman
Created2012-04-04T15:36:37.000+0000
Updated2017-06-12T19:41:24.000+0000

Description

When the imageview has no valid width or height we dont scale the underlying bitmap. This is extremely problematic since the resulting bitmap loaded into memory can be very large. We should have a default level of scaling based on screen size reported by the window manager in order to avoid run away memory usage. This can be tested with the KS camera test and setting the imageview width and height (in the success callback) to Ti.UI.FILL. Example log output resulting:

04-04 16:24:06.869 21034 21034 E GraphicsJNI: VM won't let us allocate 10036224 bytes
04-04 16:24:06.869 21034 21034 D skia    : --- decoder->decode returned false
04-04 16:24:06.900 21034 21034 E TiDrawableReference: (main) [8,524579] Unable to load bitmap. Not enough memory: bitmap size exceeds VM budget
04-04 16:24:06.900 21034 21034 E TiDrawableReference: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:459)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at org.appcelerator.titanium.view.TiDrawableReference.getBitmap(TiDrawableReference.java:285)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at org.appcelerator.titanium.view.TiDrawableReference.getBitmap(TiDrawableReference.java:521)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at ti.modules.titanium.ui.widget.TiUIImageView.setImage(TiUIImageView.java:748)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at ti.modules.titanium.ui.widget.TiUIImageView.processProperties(TiUIImageView.java:861)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:737)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:530)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:522)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:500)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:616)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:307)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:110)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at ti.modules.titanium.ui.ActivityWindowProxy.handleMessage(ActivityWindowProxy.java:93)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at android.os.Handler.dispatchMessage(Handler.java:95)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at android.os.Looper.loop(Looper.java:143)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at android.app.ActivityThread.main(ActivityThread.java:4701)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at java.lang.reflect.Method.invokeNative(Native Method)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at java.lang.reflect.Method.invoke(Method.java:521)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-04 16:24:06.900 21034 21034 E TiDrawableReference: 	at dalvik.system.NativeStart.main(Native Method)
04-04 16:24:06.916  1401  1428 D MediaProvider: current image thumbnail number created successfully is:1
04-04 16:24:06.916 21034 21034 W TiDrawableReference: (main) [47,524626] Bitmap final bounds could not be determined.  If bitmap is loaded, it won't be scaled.

Comments

  1. Lee Morris 2017-06-12

    Closing ticket as this version of KS is no longer supported.

JSON Source