My application work very well on nougat emulator and many devices, but i found this exception in google play crash reporter, I don\'t know why it happened, The exception causes
Just Resize your image in my case my Splash screen image dimensions are 1544x2100 so i changed to 1080x2100 and that will work!! Hope this will help!!! Thanks!!!
Try to set a debug point in android.view.DisplayListCanvas.throwIfCannotDraw
and check what image is throw an exception. Some of them is incorrect - large size or you have too many images for example and cant record to canvas pool.
I had the exact same problem with Samsung Galaxy S6 S7 S8
. In my case Splash Screen had high resolution and it was mistakenly placed in the drawable folder. I found solution from this answer.
drawable
-> New
-> Directory
. xxhdpi
. It will create a new folder named drawable-xxhdpi
if you go to res
drawable
to drawable-xxhdpi
. private static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024; // 100 MB
@Override
protected void throwIfCannotDraw(Bitmap bitmap) {
super.throwIfCannotDraw(bitmap);
int bitmapSize = bitmap.getByteCount();
if (bitmapSize > MAX_BITMAP_SIZE) {
throw new RuntimeException(
"Canvas: trying to draw too large(" + bitmapSize + "bytes) bitmap.");
}
}
See this code in DisplayListCanvas,otherwise look at View#draw() method,
boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
boolean drawingWithRenderNode = mAttachInfo != null
&& mAttachInfo.mHardwareAccelerated
&& hardwareAcceleratedCanvas;
···
if (drawingWithRenderNode) {
// Delay getting the display list until animation-driven alpha values are
// set up and possibly passed on to the view
renderNode = updateDisplayListIfDirty();
if (!renderNode.isValid()) {
// Uncommon, but possible. If a view is removed from the hierarchy during the call
// to getDisplayList(), the display list will be marked invalid and we should not
// try to use it again.
renderNode = null;
drawingWithRenderNode = false;
}
}
···
}
that why we can resolve the problem by cancel the hardwareAccelerated