Skip to content

[BUG] #5

@ziglee

Description

@ziglee

Describe the bug
App crashes when trying to drag the cropper component. If the .padding(24.dp) is removed, the error doesn't happen anymore.

To Reproduce
Simply try to drag the cropper.

Expected behavior
Nothing, since dragging the cropper component when it has the full size of the image, shouldn't do anything.

Screenshots
Image

Environment (please complete the following information):

  • Crop Kit Version: 1.1.0
  • Kotlin Version: 2.1.21
  • Jetpack Compose Version: 2025.07.00
  • Gradle Version: 8.14.3
  • AGP Version: 8.10.1

Test Device (please complete the following information):

  • Model: Google Pixel 7a
  • Android OS: 16
  • Type: Real

Code

val cropOptions = CropOptions(
            cropShape = CropShape.FreeForm,
            contentScale = ContentScale.Fit,
            gridLinesVisibility = GridLinesVisibility.ON_TOUCH,
            gridLinesType = GridLinesType.GRID,
            handleRadius = 8.dp,
            touchPadding = 30.dp,
        )

        val cropController = rememberCropController(
            bitmap = bitmap,
            cropOptions = cropOptions,
        )

ImageCropper(
                modifier = Modifier
                    .fillMaxSize()
                    .padding(24.dp),
                cropController = cropController
            )

Additional context

             java.lang.IllegalArgumentException: Cannot coerce value to an empty range: maximum 0.0 is less than minimum 3.0517578E-5.
             	at kotlin.ranges.RangesKt___RangesKt.coerceIn(_Ranges.kt:1442)
             	at com.tanishranjan.cropkit.internal.CropStateManager.moveCropRect-k-4lQ0M(CropStateManager.kt:148)
             	at com.tanishranjan.cropkit.internal.CropStateManager.onDrag-k-4lQ0M(CropStateManager.kt:117)
             	at com.tanishranjan.cropkit.CropController.onStateChange$cropkit_release(CropController.kt:63)
             	at com.tanishranjan.cropkit.ImageCropperKt$ImageCropper$1$1$1.invoke$lambda$2(ImageCropper.kt:83)
             	at com.tanishranjan.cropkit.ImageCropperKt$ImageCropper$1$1$1.$r8$lambda$DAhhGuPEQyFYDTlMI0R5poPBBlI(Unknown Source:0)
             	at com.tanishranjan.cropkit.ImageCropperKt$ImageCropper$1$1$1$$ExternalSyntheticLambda2.invoke(D8$$SyntheticClass:0)
             	at androidx.compose.foundation.gestures.DragGestureDetectorKt$detectDragGestures$9.invokeSuspend(DragGestureDetector.kt:306)
             	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
             	at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:163)
             	at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:152)
             	at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:470)
             	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$kotlinx_coroutines_core(CancellableContinuationImpl.kt:504)
             	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$kotlinx_coroutines_core$default(CancellableContinuationImpl.kt:493)
             	at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:359)
             	at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl$PointerEventHandlerCoroutine.offerPointerEvent(SuspendingPointerInputFilter.kt:830)
             	at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl.dispatchPointerEvent(SuspendingPointerInputFilter.kt:698)
             	at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl.onPointerEvent-H0pRuoY(SuspendingPointerInputFilter.kt:724)
             	at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:436)
             	at androidx.compose.ui.input.pointer.NodeParent.dispatchMainEventPass(HitPathTracker.kt:275)
             	at androidx.compose.ui.input.pointer.HitPathTracker.dispatchChanges(HitPathTracker.kt:171)
             	at androidx.compose.ui.input.pointer.PointerInputEventProcessor.process-BIzXfog(PointerInputEventProcessor.kt:117)
             	at androidx.compose.ui.platform.AndroidComposeView.sendMotionEvent-8iAsVTc(AndroidComposeView.android.kt:2370)
             	at androidx.compose.ui.platform.AndroidComposeView.handleMotionEvent-8iAsVTc(AndroidComposeView.android.kt:2320)
             	at androidx.compose.ui.platform.AndroidComposeView.dispatchTouchEvent(AndroidComposeView.android.kt:2191)
             	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3146)
             	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2829)
             	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3146)
             	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2829)
             	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3146)
             	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2829)
             	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3146)
             	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2829)
             	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3146)
             	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2829)
             	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3146)
             	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2829)
             	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3146)
             	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2829)
             	at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:475)

com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:2021) (Ask Gemini)
at android.app.Activity.dispatchTouchEvent(Activity.java:4604)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:433)
at android.view.View.dispatchPointerEvent(View.java:16938)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:8228)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:7987)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7369)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7426)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7392)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:7558)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:7400)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:7615)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7373)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7426)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7392)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:7400)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7373)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:10533)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:10484)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:10452)
at android.view.ViewRootImpl.processRawInputEvent(ViewRootImpl.java:10897)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:10655)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:300)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:259)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:10632)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:10747)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1570)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1579)
at android.view.Choreographer.doCallbacks(Choreographer.java:1179)
at android.view.Choreographer.doFrame(Choreographer.java:1101)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1553)
at android.os.Handler.handleCallback(Handler.java:995)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loopOnce(Looper.java:248)
at android.os.Looper.loop(Looper.java:338)
at android.app.ActivityThread.main(ActivityThread.java:9067)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@94972fc, androidx.compose.runtime.BroadcastFrameClock@36ed85, StandaloneCoroutine{Cancelling}@d9fd7da, AndroidUiDispatcher@d6f840b]

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions