Error : RuntimeException at DisplayListCanvas.throwIfCannotDraw

前端 未结 4 2326
你的背包
你的背包 2021-02-18 13:55

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

4条回答
  •  不要未来只要你来
    2021-02-18 14:50

     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

提交回复
热议问题