Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on Android #101

Open
aschulz90 opened this issue Sep 16, 2024 · 0 comments
Open

Crash on Android #101

aschulz90 opened this issue Sep 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@aschulz90
Copy link

Got a crash report in Sentry from an Andorid app.

Stacktrace:

java.lang.NullPointerException: null
    at com.preat.peekaboo.image.picker.PeekabooImageResizer.getOriginalImageByteArray
    at com.preat.peekaboo.image.picker.PeekabooImageResizer.getOriginalImageByteArray
    at com.preat.peekaboo.image.picker.PeekabooImageResizer.access$getOriginalImageByteArray
    at com.preat.peekaboo.image.picker.PeekabooImageResizer$resizeImageAsync$1$2.invokeSuspend
    at com.preat.peekaboo.image.picker.PeekabooImageResizer$resizeImageAsync$1$2.invokeSuspend
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith
    at kotlinx.coroutines.DispatchedTask.run
    at kotlinx.coroutines.DispatchedTask.run
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:236)
    at android.app.ActivityThread.main(ActivityThread.java:8061)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)

The offending code is:

return context.contentResolver.openInputStream(uri)?.use { inputStream ->
    val bitmap = BitmapFactory.decodeStream(inputStream)
    val rotatedBitmap = rotateImageIfRequired(context, bitmap, uri)

    ByteArrayOutputStream().apply {
        rotatedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, this)
    }.toByteArray()
}

The documentation for BitmapFactory.decodeStream mentions, that it can return null. So thats most likely where the NullPointer originates from. Maybe the user picked an invalid image somehow.

@onseok onseok added the bug Something isn't working label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants