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

ArrayIndexOutOfBoundsException at ja.burhanrashid52.photoeditor.BitmapUtil.removeTransparency (BitmapUtil.java:46) #263

Closed
ankitbatra11 opened this issue Jul 24, 2020 · 12 comments
Labels
bug Something isn't working release.1.1.0

Comments

@ankitbatra11
Copy link

ankitbatra11 commented Jul 24, 2020

I have crash reports of ArrayIndexOutOfBoundsException through Crashlytics in my app:

java.lang.RuntimeException: at android.os.AsyncTask$3.done (AsyncTask.java:353) at java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:383) at java.util.concurrent.FutureTask.setException (FutureTask.java:252) at java.util.concurrent.FutureTask.run (FutureTask.java:271) at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:245) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636) at java.lang.Thread.run (Thread.java:764) Caused by: java.lang.ArrayIndexOutOfBoundsException: at ja.burhanrashid52.photoeditor.BitmapUtil.removeTransparency (BitmapUtil.java:46) at ja.burhanrashid52.photoeditor.PhotoEditor$6$1.doInBackground (PhotoEditor.java:743) at ja.burhanrashid52.photoeditor.PhotoEditor$6$1.doInBackground (PhotoEditor.java:730) at android.os.AsyncTask$2.call (AsyncTask.java:333) at java.util.concurrent.FutureTask.run (FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:245) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636) at java.lang.Thread.run (Thread.java:764)

Unfortunately, I cannot provide any more information at the moment other than this.

I am using implementation 'ja.burhanrashid52:photoeditor:1.0.0'

@AdhseOne
Copy link

I have crash reports of ArrayIndexOutOfBoundsException through Crashlytics in my app:

java.lang.RuntimeException: at android.os.AsyncTask$3.done (AsyncTask.java:353) at java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:383) at java.util.concurrent.FutureTask.setException (FutureTask.java:252) at java.util.concurrent.FutureTask.run (FutureTask.java:271) at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:245) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636) at java.lang.Thread.run (Thread.java:764) Caused by: java.lang.ArrayIndexOutOfBoundsException: at ja.burhanrashid52.photoeditor.BitmapUtil.removeTransparency (BitmapUtil.java:46) at ja.burhanrashid52.photoeditor.PhotoEditor$6$1.doInBackground (PhotoEditor.java:743) at ja.burhanrashid52.photoeditor.PhotoEditor$6$1.doInBackground (PhotoEditor.java:730) at android.os.AsyncTask$2.call (AsyncTask.java:333) at java.util.concurrent.FutureTask.run (FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:245) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636) at java.lang.Thread.run (Thread.java:764)

Unfortunately, I cannot provide any more information at the moment other than this.

I am using implementation 'ja.burhanrashid52:photoeditor:1.0.0'

Mmm ... it seems that you are sending a Bitmap, which is not null, but has not finished generating and possibly its measurements are 0.

@Parag2385
Copy link

@ankitbatra11 Same here, I'm also observing this exception in Crashlytics, Did you find a solution to it?

@ankitbatra11
Copy link
Author

I believe that this could be triggered if I let the user click the Save edited image button multiple times without letting the user wait (via a progress bar) until the edited image from the previous Save button click is saved. '

Hence, I am currently adding a progress bar on Save click so as to not let the user go mad with the Save button if saving the edited image takes time. It may or may not fix the issue but is anyway a good change for my app.

@Parag2385
Copy link

@ankitbatra11 Ohh yeah, makes sense, depending on the size of the processed image, it could take different time on different devices, might take more time on lower-end devices. Thanks, I'll also try this.

@ankitbatra11
Copy link
Author

Happened to see another occurrence in the production instance of my app

Caused by java.lang.ArrayIndexOutOfBoundsException: length=1501200; index=1501200
       at ja.burhanrashid52.photoeditor.BitmapUtil.removeTransparency(BitmapUtil.java:46)
       at ja.burhanrashid52.photoeditor.PhotoEditor$6$1.doInBackground(PhotoEditor.java:743)
       at ja.burhanrashid52.photoeditor.PhotoEditor$6$1.doInBackground(PhotoEditor.java:730)
       at android.os.AsyncTask$2.call(AsyncTask.java:333)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
       at java.lang.Thread.run(Thread.java:764)

Looks like a bug in the code snippet below (taken from BitmapUtil.removeTransparency)

loop:
        for (int y = 0; y < source.getHeight(); y++) {
            for (int x = firstX; x < source.getHeight(); x++) {
                if (pixels[x + (y * source.getWidth())] != Color.TRANSPARENT) {
                    firstY = y;
                    break loop;
                }
            }
        }

for (int x = firstX; x < source.getHeight(); x++) { should be for (int x = firstX; x < source.getWidth(); x++) {

@ankitbatra11
Copy link
Author

@burhanrashid52 Would you be able to take a look at the PR?

@burhanrashid52
Copy link
Owner

@ankitbatra11 Thanks for the PR. I will have a look at it. Are you able to reproduce the issue in your device, because it will help us to verify the fix.

@burhanrashid52
Copy link
Owner

Merged in release.1.1.0

@burhanrashid52 burhanrashid52 added bug Something isn't working release.1.1.0 labels Sep 15, 2020
@Parag2385
Copy link

Have you released the version 1.1.0? as it's not showing up on bintray.
https://bintray.com/burhanrashid52/maven/photoeditor

@burhanrashid52
Copy link
Owner

Not yet. Need to review other PR as well. Once it get merged I will release it. I should've not closed this ticket.

@Parag2385
Copy link

Is there any chance that you'll be releasing it by Friday? As I'm releasing an app update on Friday and I see a lot of users having this error/crash on their devices. If you could release it by Friday that would be really great. Thanks.

@ankitbatra11
Copy link
Author

@ankitbatra11 Thanks for the PR. I will have a look at it. Are you able to reproduce the issue in your device, because it will help us to verify the fix?

Sorry, can't reproduce it. Already using the fix in the production instance of my app. Will try to update here if I see this issue again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working release.1.1.0
Projects
None yet
Development

No branches or pull requests

4 participants