Glide Version:
Glide version:4.6.1
Integration libraries:
Device/Android Version:
Device/Android Version: samsung and xiaomi above android 7.0 (mostly 7.0).
All the devices with resolution 1920x1080
Issue details / Repro steps / Use case background:
My app uses recyclerview only in one place, and I use glide to load bitmap.
The log:
Fatal Exception: java.lang.RuntimeException: Canvas: trying to draw too large(123336000bytes) bitmap.
at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:260)
at android.graphics.Canvas.drawBitmap(Canvas.java:1420)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:545)
at android.widget.ImageView.onDraw(ImageView.java:1286)
at android.view.View.draw(View.java:18398)
at android.view.View.updateDisplayListIfDirty(View.java:17376)
at android.view.View.draw(View.java:18160)
at android.view.ViewGroup.drawChild(ViewGroup.java:3968)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3754)
at android.view.View.draw(View.java:18401)
at android.view.View.updateDisplayListIfDirty(View.java:17376)
at android.view.View.draw(View.java:18160)
at android.view.ViewGroup.drawChild(ViewGroup.java:3968)
at android.widget.ListView.drawChild(ListView.java:3728)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3754)
at android.widget.AbsListView.dispatchDraw(AbsListView.java:3483)
at android.widget.ListView.dispatchDraw(ListView.java:3711)
at android.view.View.draw(View.java:18401)
at android.widget.AbsListView.draw(AbsListView.java:6994)
at android.view.View.updateDisplayListIfDirty(View.java:17376)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3952)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3932)
at android.view.View.updateDisplayListIfDirty(View.java:17339)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3952)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3932)
at android.view.View.updateDisplayListIfDirty(View.java:17339)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3952)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3932)
at android.view.View.updateDisplayListIfDirty(View.java:17339)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3952)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3932)
at android.view.View.updateDisplayListIfDirty(View.java:17339)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3952)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3932)
at android.view.View.updateDisplayListIfDirty(View.java:17339)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3952)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3932)
at android.view.View.updateDisplayListIfDirty(View.java:17339)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:722)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:728)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:836)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3168)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2964)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2552)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1537)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:959)
at android.view.Choreographer.doCallbacks(Choreographer.java:734)
at android.view.Choreographer.doFrame(Choreographer.java:670)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:945)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
The bitmap size is 123336000bytes, All my bitmap size is 495x880 in 1080x1920 devices.
so I think Glide make the wrong scale.
Code:
int height = 880;
int width = 495;
ViewGroup.LayoutParams imageParams = holder.previewView.getLayoutParams();
imageParams.height = height;
imageParams.width = width;
holder.previewView.setLayoutParams(imageParams);
Glide.with(context).load(theme.getPreviewUrl()).apply(RequestOptions.placeholderOf(R.drawable.theme_preview).override(width,height)).into(holder.previewView);
It is in recyclerview adapter.
sorry I cann`t reproduce the error currently
Have you solved the problem?
@bigzx no...
It happens, when your process is going to OUT OF MEMORY. As per my findings.
@NiaNingXue try to apply request option fitCenter:
Glide.with(context)
.load(url)
.apply(new RequestOptions().fitCenter())
.into(view);
@aaivanyutenko Thanks i will try.
The log is strange. because i don`t use recyclerview in my code....
maybe it's because you put the bitmap in the wrong folder, ref this.
Hi, I was also facing the same issue. I have fixed the issue with image size, I will be better to pass width and height with screen size.
Glide
.with(context)
.load(path)
.apply(new RequestOptions().override(600, 200))
.into(imageViewResizeCenterCrop);
has anyone figured out this issue?
has anyone figured out this issue?
Just avoid using too big by dimensions pictures.
Most helpful comment
@NiaNingXue try to apply request option fitCenter: