Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

OOM trying to draw a button on Android

$
0
0

I got an OOM trying to allocate 601212 bytes for a bitmap while trying to draw a button. This only happened once (the device was fairly low in memory, so maybe I usually create a large bitmap?)

Looking at the stack trace, it appears to be the button that is inside my listview.
I have a list of five buttons, they are fairly simple. I set an image (a 28x28 images for the base device) and some text.

We are using 1.4.2.6359 (I haven't been able to upgrade to the next version due to issues with Google Maps)
None of my resources, in any of the drawable folders are even close to this size. So why is it try to create such a large button?

My XAML:
`

  <ListView.ItemTemplate>
    <DataTemplate>
      <ViewCell>
        <Grid Padding="0,10,0,10">
        <Button Image="{Binding Icon}"
                Text="{Binding Name}"
                BackgroundColor="{x:Static local:AppConstants.ButtonColor}"
                TextColor="{x:Static local:AppConstants.TextColor}"
                CommandParameter="{Binding .}"
                            Clicked="OnCategoryClicked"/>
        </Grid>
      </ViewCell>
    </DataTemplate>
  </ListView.ItemTemplate>
</ListView>

`

The crash:

System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Android.Runtime.JNIEnv.CallStaticObjectMethod(intptr, intptr, JValue*)
at Android.Graphics.Bitmap.CreateBitmap (int,int,Android.Graphics.Bitmap/Config) <0x001d7>
Xamarin.Forms.Platform.Android.ButtonDrawable.CreateBitmap(bool, int, int)
Xamarin.Forms.Platform.Android.ButtonDrawable.Draw(Canvas)
Android.Graphics.Drawables.Drawable.n_Draw_Landroid_graphics_Canvas_(intptr, intptr, intptr)
at (wrapper dynamic-method) object.484ebec9-cba7-4a9f-af85-9922d562ecd3 (intptr,intptr,intptr) <0x00043>
--- End of managed exception stack trace ---
java.lang.OutOfMemoryError: Failed to allocate a 601212 byte allocation with 183128 free bytes and 178KB until OOM
dalvik.system.VMRuntime.newNonMovableArray(Native Method)
android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:939)
at android.graphics.Bitmap.createBitmap(Bitmap.java:912)
at android.graphics.Bitmap.createBitmap(Bitmap.java:879)
md5530bd51e982e6e7b340b73e88efe666e.ButtonDrawable.n_draw(Native Method)
at md5530bd51e982e6e7b340b73e88efe666e.ButtonDrawable.draw(ButtonDrawable.java:49)
at android.view.View.getDrawableRenderNode(View.java:16342)
at android.view.View.drawBackground(View.java:16293)
at android.view.View.draw(View.java:16059)
at android.view.View.updateDisplayListIfDirty(View.java:14999)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.updateDisplayListIfDirty(View.java:14994)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.updateDisplayListIfDirty(View.java:14994)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.updateDisplayListIfDirty(View.java:14994)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.updateDisplayListIfDirty(View.java:14994)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.updateDisplayListIfDirty(View.java:14994)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.draw(View.java:16071)
at android.widget.FrameLayout.draw(FrameLayout.java:592)
at android.widget.ScrollView.draw(ScrollView.java:2484)
at android.view.View.updateDisplayListIfDirty(View.java:14999)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.updateDisplayListIfDirty(View.java:14994)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.draw(View.java:16071)
at android.view.View.updateDisplayListIfDirty(View.java:14999)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.draw(View.java:16071)
at android.view.View.updateDisplayListIfDirty(View.java:14999)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.updateDisplayListIfDirty(View.java:14994)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.updateDisplayListIfDirty(View.java:14994)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.updateDisplayListIfDirty(View.java:14994)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.updateDisplayListIfDirty(View.java:14994)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.draw(View.java:16071)
at com.android.internal.widget.ActionBarOverlayLayout.draw(ActionBarOverlayLayout.java:501)
at android.view.View.updateDisplayListIfDirty(View.java:14999)
at android.view.View.getDisplayList(View.java:15022)
at android.view.View.draw(View.java:15789)
at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
at android.view.View.draw(View.java:16071)
at android.widget.FrameLayout.draw(FrameLayout.java:592)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2916)
at android.view.View.updateDisplayListIfDirty(View.java:14999)
at android.view.View.getDisplayList(View.java:15022)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:275)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:281)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:320)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2745)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2577)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2169)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1180)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6563)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
at android.view.Choreographer.doCallbacks(Choreographer.java:590)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5835)
java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Viewing all articles
Browse latest Browse all 91519

Trending Articles