question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ankitbatra11commented, Sep 4, 2020

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++) {

0reactions
ankitbatra11commented, Sep 15, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What causes a java.lang.ArrayIndexOutOfBoundsException ...
Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found