Skip to content

Conversation

@Ch3D
Copy link

@Ch3D Ch3D commented Aug 2, 2018

…ion.Op - only INTERSECT and DIFFERENCE are allowed
@jagrulez247
Copy link

@ArthurHub Please review this and add the fix. We have the same crash on Android P devices on our app -

Process: *.*, PID: 22108
 java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed
 at android.graphics.Canvas.checkValidClipOp(Canvas.java:779)
 at android.graphics.Canvas.clipPath(Canvas.java:1007)
 at com.theartofdev.edmodo.cropper.CropOverlayView.drawBackground(CropOverlayView.java:635)
 at com.theartofdev.edmodo.cropper.CropOverlayView.onDraw(CropOverlayView.java:579)
 at android.view.View.draw(View.java:20207)
 at android.view.View.updateDisplayListIfDirty(View.java:19082)
 at android.view.View.draw(View.java:19935)
 at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
 at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
 at android.view.View.updateDisplayListIfDirty(View.java:19073)
 at android.view.View.draw(View.java:19935)
 at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
 at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
 at android.view.View.updateDisplayListIfDirty(View.java:19073)
 at android.view.View.draw(View.java:19935)
 at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
 at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
 at android.view.View.updateDisplayListIfDirty(View.java:19073)
 at android.view.View.draw(View.java:19935)
 at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
 at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
 at android.view.View.updateDisplayListIfDirty(View.java:19073)
 at android.view.View.draw(View.java:19935)
 at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
 at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
 at android.view.View.updateDisplayListIfDirty(View.java:19073)
 at android.view.View.draw(View.java:19935)
 at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
 at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
 at android.view.View.draw(View.java:20210)
 at com.android.internal.policy.DecorView.draw(DecorView.java:780)
 at android.view.View.updateDisplayListIfDirty(View.java:19082)
 at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:686)
 at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:692)
 at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:801)
 at android.view.ViewRootImpl.draw(ViewRootImpl.java:3312)
 at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3116)
 at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2485)
 at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460)
 at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7184)
 at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
 at android.view.Choreographer.doCallbacks(Choreographer.java:761)
 at android.view.Choreographer.doFrame(Choreographer.java:696)
 at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
 at android.os.Handler.handleCallback(Handler.java:873)
 at android.os.Handler.dispatchMessage(Handler.java:99)
 at android.os.Looper.loop(Looper.java:193)
 at android.app.ActivityThread.main(ActivityThread.java:6669)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

@smelfungus
Copy link

smelfungus commented Sep 4, 2018

@ArthurHub same here, It would be great to take an action, thank you.

@abhishekagra
Copy link

Any update guys? I am also facing the same issue in Android Pie. If you know any workaround, then please let me know.

@nthreads
Copy link

nthreads commented Sep 9, 2018

This can be resolved by the following changes in CropOverlayView

canvas.clipPath(mPath, Region.Op.XOR); //Deprecated
//https://developer.android.com/reference/android/graphics/Canvas#clipPath(android.graphics.Path,%20android.graphics.Region.Op)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    canvas.clipOutPath(mPath);
} else {
    canvas.clipPath(mPath, Region.Op.INTERSECT);
}

@rishabhsri20
Copy link

When is this fix releasing?

@nthreads
Copy link

When is this fix releasing?

Committed changes already, waiting for the merged release.

@amenon
Copy link

amenon commented Sep 18, 2018

I'm also seeing this crash in the wild on devices running Android Pie. @ArthurHub, could this PR please be merged?

Ramificate added a commit to Ramificate/Android-Image-Cropper that referenced this pull request Sep 19, 2018
@ericbatemandev
Copy link

Any update on this PR merge?

@chooven
Copy link

chooven commented Oct 10, 2018

I looked at the PR 600 and I may be missing something bit it looks like the "fix" is on the wrong call.
the commit in the PR is
//canvas.clipRect(rect, Region.Op.XOR);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
canvas.clipRect(rect);
} else {
canvas.clipRect(rect, Region.Op.INTERSECT);
}

However, the bug is
Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed
at android.graphics.Canvas.checkValidClipOp(Canvas.java:779)
at android.graphics.Canvas.clipPath(Canvas.java:1007)

proposed fix should be.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
canvas.clipOutPath(mPath);
} else {
canvas.clipPath(mPath, Region.Op.INTERSECT);
}

@ericbatemandev
Copy link

@chooven this is also where I am seeing the crash

@ArthurHub
Copy link
Owner

ArthurHub commented Oct 27, 2018

merged #618
sorry for being late

@ArthurHub ArthurHub closed this Oct 27, 2018
@hssnsdsol
Copy link

This can be resolved by the following changes in CropOverlayView

canvas.clipPath(mPath, Region.Op.XOR); //Deprecated
//https://developer.android.com/reference/android/graphics/Canvas#clipPath(android.graphics.Path,%20android.graphics.Region.Op)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    canvas.clipOutPath(mPath);
} else {
    canvas.clipPath(mPath, Region.Op.INTERSECT);
}

Thanks Man, That works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.