lopspower / CircularImageView

Create circular ImageView in Android in the simplest way possible
Apache License 2.0
1.95k stars 413 forks source link

Crash , when Inflate in the view. #53

Closed Awais-Ali closed 6 years ago

Awais-Ali commented 8 years ago

Adapter or main fragment , behavior is same... as

android.view.InflateException: Binary XML file line #79: Error inflating class <unknown>
                                                                       at android.view.LayoutInflater.createView(LayoutInflater.java:640)
                                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
                                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
                                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
                                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
                                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
                                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
                                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
                                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
                                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
                                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
                                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
                                                                       at com.algorepublic.zoho.adapters.AdapterUser.getView(AdapterUser.java:57)
                                                                       at android.widget.AbsListView.obtainView(AbsListView.java:2820)
Rainer-Lang commented 8 years ago

+1

HarryMMR commented 8 years ago

Found the root cause. I have managed to reproduce it. I recreated the activity many times. Then OOME happens. Somebody please let us know how to fix it!

                                                                       java.lang.OutOfMemoryError: Failed to allocate a 4410012 byte allocation with 2828720 free bytes and 2MB until OOM
                                                                           at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
                                                                           at android.graphics.Bitmap.nativeCreate(Native Method)
                                                                           at android.graphics.Bitmap.createBitmap(Bitmap.java:831)
                                                                           at android.graphics.Bitmap.createBitmap(Bitmap.java:808)
                                                                           at android.graphics.Bitmap.createBitmap(Bitmap.java:728)
                                                                           at android.graphics.Bitmap.createBitmap(Bitmap.java:653)
                                                                           at com.mikhaellopez.circularimageview.CircularImageView.cropBitmap(CircularImageView.java:200)
                                                                           at com.mikhaellopez.circularimageview.CircularImageView.updateShader(CircularImageView.java:183)
                                                                           at com.mikhaellopez.circularimageview.CircularImageView.loadBitmap(CircularImageView.java:156)
                                                                           at com.mikhaellopez.circularimageview.CircularImageView.onDraw(CircularImageView.java:127)
                                                                           at android.view.View.draw(View.java:16256)
                                                                           at android.view.View.buildDrawingCacheImpl(View.java:15553)
                                                                           at android.view.View.buildDrawingCache(View.java:15414)
                                                                           at android.view.View.updateDisplayListIfDirty(View.java:15234)
                                                                           at android.view.View.draw(View.java:16026)
                                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
                                                                           at android.support.design.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1127)
                                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
                                                                           at android.view.View.updateDisplayListIfDirty(View.java:15248)
                                                                           at android.view.View.draw(View.java:16026)
                                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
                                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
                                                                           at android.view.View.updateDisplayListIfDirty(View.java:15248)
                                                                           at android.view.View.draw(View.java:16026)
                                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
                                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
                                                                           at android.view.View.draw(View.java:16259)
                                                                           at android.view.View.updateDisplayListIfDirty(View.java:15253)
                                                                           at android.view.View.draw(View.java:16026)
                                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
                                                                           at android.support.design.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1127)
                                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
                                                                           at android.view.View.draw(View.java:16259)
                                                                           at android.view.View.updateDisplayListIfDirty(View.java:15253)
                                                                           at android.view.View.draw(View.java:16026)
                                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
                                                                           at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1373)
                                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
                                                                           at android.view.View.draw(View.java:16259)
                                                                           at android.view.View.updateDisplayListIfDirty(View.java:15253)
                                                                           at android.view.View.draw(View.java:16026)
                                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
                                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
                                                                           at android.view.View.updateDisplayListIfDirty(View.java:15248)
                                                                           at android.view.View.draw(View.java:16026)
                                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
                                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
                                                                           at android.view.View.updateDisplayListIfDirty(View.java:15248)
                                                                           at android.view.View.draw(View.java:16026)
                                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
                                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
                                                                           at android.view.View.updateDisplayListIfDirty(View.java:15248)
                                                                           at android.view.View.draw(View.java:16026)
                                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
                                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
                                                                           at android.view.View.updateDisplayListIfDirty(View.java:15248)
                                                                           at android.view.View.draw(View.java:16026)
                                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
                                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
                                                                           at android.view.View.draw(View.java:16259)
                                                                           at com.android.internal.policy.PhoneWindow$DecorView.draw(PhoneWindow.java:2697)
                                                                           at android.view.View.updateDisplayListIfDirty(View.java:15253)
                                                                           at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281)
                                                                          at android.view.ThreadedRenderer.updateRoo
FelipeRRM commented 8 years ago

+1, it crashes when used on a view recycled on a RecyclerView!

ashmosaheb commented 7 years ago

+1

lopspower commented 6 years ago

Fix on https://github.com/lopspower/CircularImageView/commit/227d12eb399ab18a54b06fd63f94b68d6d0493eb This memory leak comes from cropBitmap method. I removed it and I changed the technique to auto center crop image in view.