Skip to content

Crash: java.lang.IllegalArgumentException - expo.modules.imagemanipulator.actions.CropAction.run (CropAction.kt:14) #42038

Closed

Description

@Beamanator

Versions: 1.4.70-*, 1.4.72-0

https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues/bce5b50f210270b623ec8153d7c2fe05?time=last-seven-days&types=crash&sessionEventKey=663D1A3D00FF00016C07288BD5375B41_1945519131403945350

Caused by java.lang.IllegalArgumentException
x + width must be <= bitmap.width()

android.graphics.Bitmap.createBitmap (Bitmap.java:881)
...
android.graphics.Bitmap.createBitmap (Bitmap.java:841)
expo.modules.imagemanipulator.actions.CropAction.run (CropAction.kt:14)
expo.modules.imagemanipulator.ImageManipulatorModule.runActions (ImageManipulatorModule.kt:44)
expo.modules.imagemanipulator.ImageManipulatorModule.access$runActions (ImageManipulatorModule.kt:19)
expo.modules.imagemanipulator.ImageManipulatorModule$definition$1$1$1.onSuccess (ImageManipulatorModule.kt:32)
expo.modules.imageloader.ImageLoaderModule$loadImageForManipulationFromURL$2.onResourceReady (ImageLoaderModule.kt:84)
expo.modules.imageloader.ImageLoaderModule$loadImageForManipulationFromURL$2.onResourceReady (ImageLoaderModule.kt:82)
com.bumptech.glide.request.SingleRequest.onResourceReady (SingleRequest.java:667)
com.bumptech.glide.request.SingleRequest.onResourceReady (SingleRequest.java:596)
com.bumptech.glide.load.engine.EngineJob.callCallbackOnResourceReady (EngineJob.java:159)
com.bumptech.glide.load.engine.EngineJob$CallResourceReady.run (EngineJob.java:428)
com.bumptech.glide.load.engine.EngineJob$CallLoadFailed.run (EngineJob.java:6)
android.os.Handler.handleCallback (Handler.java:942)
...
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)

Galaxy A32 5G | Android 13

Issue OwnerCurrent Issue Owner: @parasharrajat

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on May 13, 2024
  2. self-assigned this
    on May 13, 2024
  3. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 13, 2024
  4. melvin-bot commented on May 13, 2024

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @parasharrajat (External)

  5. ShridharGoel commented on May 13, 2024

    @ShridharGoel
    Contributor

    @Beamanator Can you share the full stacktrace?

  6. Beamanator commented on May 13, 2024

    @Beamanator
    ContributorAuthor

    Sure thing @ShridharGoel ! here's the full stack trace:

    android.graphics.Bitmap.createBitmap (Bitmap.java:881)
    android.graphics.Bitmap.createBitmap (Bitmap.java:841)
    expo.modules.imagemanipulator.actions.CropAction.run (CropAction.kt:14)
    expo.modules.imagemanipulator.ImageManipulatorModule.runActions (ImageManipulatorModule.kt:44)
    expo.modules.imagemanipulator.ImageManipulatorModule.access$runActions (ImageManipulatorModule.kt:19)
    expo.modules.imagemanipulator.ImageManipulatorModule$definition$1$1$1.onSuccess (ImageManipulatorModule.kt:32)
    expo.modules.imageloader.ImageLoaderModule$loadImageForManipulationFromURL$2.onResourceReady (ImageLoaderModule.kt:84)
    expo.modules.imageloader.ImageLoaderModule$loadImageForManipulationFromURL$2.onResourceReady (ImageLoaderModule.kt:82)
    com.bumptech.glide.request.SingleRequest.onResourceReady (SingleRequest.java:667)
    com.bumptech.glide.request.SingleRequest.onResourceReady (SingleRequest.java:596)
    com.bumptech.glide.load.engine.EngineJob.callCallbackOnResourceReady (EngineJob.java:159)
    com.bumptech.glide.load.engine.EngineJob$CallResourceReady.run (EngineJob.java:428)
    com.bumptech.glide.load.engine.EngineJob$CallLoadFailed.run (EngineJob.java:6)
    android.os.Handler.handleCallback (Handler.java:942)
    android.os.Handler.dispatchMessage (Handler.java:99)
    android.os.Looper.loopOnce (Looper.java:226)
    android.os.Looper.loop (Looper.java:313)
    android.app.ActivityThread.main (ActivityThread.java:8762)
    java.lang.reflect.Method.invoke (Method.java)
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:604)
    com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)
    
  7. ShridharGoel commented on May 13, 2024

    @ShridharGoel
    Contributor

    @Beamanator Any idea why it isn't showing the source of the crash in E/App? Like the method name/line numbers.

  8. tienifr commented on May 13, 2024

    @tienifr
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Crash: java.lang.IllegalArgumentException - expo.modules.imagemanipulator.actions.CropAction.run

    What is the root cause of that problem?

    The crash x + width must be <= bitmap.width() means that the width and originX here has sum larger than the image original width, so it's unable to crop. Since when calculating originX here, we use a lot of division and multiply operation, the originX could end up being slightly larger than its maximum possible value, due to JS rounding mechanism, leading to originX + width is larger than image original width and the crash occurs.

    What changes do you think we should make in order to solve the problem?

    In here, we should use Math.min to limit originX value to originalImageWidth.value - size, so originX + width cannot be larger than the originalImageWidth.value.

    We should also do similarly for originY

    What alternative solutions did you explore? (Optional)

    NA

  9. parasharrajat commented on May 13, 2024

    @parasharrajat
    Member

    @tienifr How did you come up with the error source? Were you able to reproduce this successfully?

  10. Beamanator commented on May 14, 2024

    @Beamanator
    ContributorAuthor

    @ShridharGoel firebase crashes often don't lead all the way to the source in E/App, probably because the JS code is minified when we build & deploy it. I'm not exactly sure if there's something we can do to make that work, if you can figure it out I'm sure we'd love to have that :D

  11. tienifr commented on May 14, 2024

    @tienifr
    Contributor

    @tienifr How did you come up with the error source?

    @parasharrajat I found it by looking at the error logs, it's related to the expo.modules.imagemanipulator, while the user is cropping the image (CropAction)

    Were you able to reproduce this successfully?

    Not by user action, but if I manually modify the values (originX, width) to a slightly larger number then it will crash similarly, I think it will be quite hard to reproduce by user action since this relates to JS rounding mechanism, it might happen at a specific image size and zooming level. My solution will help mitigate that.

  12. parasharrajat commented on May 14, 2024

    @parasharrajat
    Member

    @Beamanator may be you can use the info provided by @tienifr and logging console to reproduce issue. There might be something useful to determine the image used which caused this like device id etc.

    Unless we are able to reproduce this, I don't think we should try to change the code.

  13. Beamanator commented on May 15, 2024

    @Beamanator
    ContributorAuthor

    I would prefer if we only write up a fix if we are able to reproduce, but I can also see how @tienifr 's changes would "fix" the issue - I would propose we keep this open for a bit, with Needs Reproduction to see if anyone can find out how to consistently reproduce the issue. If we can't / if this doesn't happen again, we can decide to close or implement the "fix"

  14. 9 remaining items

  15. Beamanator commented on May 27, 2024

    @Beamanator
    ContributorAuthor

    Looks like this crash happened a few more times this week on v1.4.74-6, with this stack trace given:

    android.graphics.Bitmap.createBitmap (Bitmap.java:913)
    android.graphics.Bitmap.createBitmap (Bitmap.java:872)
    expo.modules.imagemanipulator.actions.CropAction.run (CropAction.kt:14)
    expo.modules.imagemanipulator.ImageManipulatorModule.runActions (ImageManipulatorModule.kt:44)
    expo.modules.imagemanipulator.ImageManipulatorModule.access$runActions (ImageManipulatorModule.kt:19)
    expo.modules.imagemanipulator.ImageManipulatorModule$definition$1$1$1.onSuccess (ImageManipulatorModule.kt:32)
    expo.modules.imageloader.ImageLoaderModule$loadImageForManipulationFromURL$2.onResourceReady (ImageLoaderModule.kt:84)
    expo.modules.imageloader.ImageLoaderModule$loadImageForManipulationFromURL$2.onResourceReady (ImageLoaderModule.kt:82)
    com.bumptech.glide.request.SingleRequest.onResourceReady (SingleRequest.java:667)
    com.bumptech.glide.request.SingleRequest.onResourceReady (SingleRequest.java:596)
    com.bumptech.glide.load.engine.EngineJob.callCallbackOnResourceReady (EngineJob.java:159)
    com.bumptech.glide.load.engine.EngineJob$CallResourceReady.run (EngineJob.java:428)
    com.bumptech.glide.load.engine.EngineJob$CallLoadFailed.run (EngineJob.java:6)
    android.os.Handler.handleCallback (Handler.java:958)
    android.os.Handler.dispatchMessage (Handler.java:99)
    android.os.Looper.loopOnce (Looper.java:230)
    android.os.Looper.loop (Looper.java:319)
    android.app.ActivityThread.main (ActivityThread.java:8919)
    java.lang.reflect.Method.invoke (Method.java)
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:578)
    com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)
    
  16. Beamanator commented on May 27, 2024

    @Beamanator
    ContributorAuthor

    So I think we should keep this open to try to get some help reproducing

  17. parasharrajat commented on May 27, 2024

    @parasharrajat
    Member

    @Beamanator Is there a way from logs to map it to a particular action? If we can find out what API was called and what the action was, it will help.

    I guess that internal team would have more info to reproduce this.

  18. parasharrajat commented on May 29, 2024

    @parasharrajat
    Member

    No updates.

  19. Beamanator commented on May 29, 2024

    @Beamanator
    ContributorAuthor

    @Beamanator Is there a way from logs to map it to a particular action? If we can find out what API was called and what the action was, it will help.

    I don't know of any way to do this, sadly... I say lets drop this to weekly while we wait, and we'll see if this crash keeps happening

  20. melvin-bot commented on Jun 21, 2024

    @melvin-bot

    This issue has not been updated in over 15 days. @Beamanator, @parasharrajat eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

  21. parasharrajat commented on Jun 22, 2024

    @parasharrajat
    Member

    @Beamanator Any updates?

  22. Beamanator commented on Jun 24, 2024

    @Beamanator
    ContributorAuthor

    Looks like this hasn't occurred since a bit after June 3, so let's close it out!

    Screenshot 2024-06-24 at 11 04 09 AM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsMonthlyKSv2Needs ReproductionReproducible steps needed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions