Issue: Editor Crashing When Sticker is Larger Than Image or Placed Outside Image
Description:
The photo editor crashes when a sticker is either larger than the image itself or placed outside the image boundaries. This issue disrupts the editing experience and requires a restart of the app to recover.
Environment:
React: 17.0.2
React Native: 0.68.7
@baronha/react-native-photo-editor: ^1.1.6
Device/OS: Android
Steps to Reproduce:
Open the photo editor.
Add an landscape image to edit.
Select a sticker and place it on the image.
Resize the sticker to be larger than the image or move the sticker outside the image boundaries.
Observe the crash.
Expected Behavior:
The photo editor should handle stickers gracefully, even if they are larger than the image or placed outside the image boundaries. It should not crash, sticker should get cropped accordingky
Actual Behavior:
The photo editor crashes when a sticker is resized to be larger than the image or placed outside the image boundaries.
Logs:
native exception java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:415)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:381)
at java.util.concurrent.FutureTask.setException(FutureTask.java:250)
at java.util.concurrent.FutureTask.run(FutureTask.java:269)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 0
at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
at java.util.Objects.checkIndex(Objects.java:359)
at java.util.ArrayList.get(ArrayList.java:434)
at android.view.ViewGroup.getAndVerifyPreorderedView(ViewGroup.java:3811)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4342)
at android.view.View.draw(View.java:23699)
at android.view.ViewGroup.drawChild(ViewGroup.java:4586)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4344)
at android.view.View.draw(View.java:23850)
at ja.burhanrashid52.photoeditor.PhotoSaverTask.captureView(PhotoSaverTask.java:161)
at ja.burhanrashid52.photoeditor.PhotoSaverTask.buildBitmap(PhotoSaverTask.java:104)
at ja.burhanrashid52.photoeditor.PhotoSaverTask.saveImageInFile(PhotoSaverTask.java:88)
at ja.burhanrashid52.photoeditor.PhotoSaverTask.doInBackground(PhotoSaverTask.java:70)
at ja.burhanrashid52.photoeditor.PhotoSaverTask.doInBackground(PhotoSaverTask.java:23)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
Issue: Editor Crashing When Sticker is Larger Than Image or Placed Outside Image
Description: The photo editor crashes when a sticker is either larger than the image itself or placed outside the image boundaries. This issue disrupts the editing experience and requires a restart of the app to recover.
Environment:
Steps to Reproduce:
Expected Behavior: The photo editor should handle stickers gracefully, even if they are larger than the image or placed outside the image boundaries. It should not crash, sticker should get cropped accordingky
Actual Behavior: The photo editor crashes when a sticker is resized to be larger than the image or placed outside the image boundaries.
Screenshots/Video:
https://github.com/baronha/react-native-photo-editor/assets/67644300/4b5b63d6-003c-46e2-b628-60b8f3ac2d73
Logs: native exception java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$4.done(AsyncTask.java:415) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:381) at java.util.concurrent.FutureTask.setException(FutureTask.java:250) at java.util.concurrent.FutureTask.run(FutureTask.java:269) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) at java.lang.Thread.run(Thread.java:1012) Caused by: java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 0 at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) at java.util.Objects.checkIndex(Objects.java:359) at java.util.ArrayList.get(ArrayList.java:434) at android.view.ViewGroup.getAndVerifyPreorderedView(ViewGroup.java:3811) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4342) at android.view.View.draw(View.java:23699) at android.view.ViewGroup.drawChild(ViewGroup.java:4586) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4344) at android.view.View.draw(View.java:23850) at ja.burhanrashid52.photoeditor.PhotoSaverTask.captureView(PhotoSaverTask.java:161) at ja.burhanrashid52.photoeditor.PhotoSaverTask.buildBitmap(PhotoSaverTask.java:104) at ja.burhanrashid52.photoeditor.PhotoSaverTask.saveImageInFile(PhotoSaverTask.java:88) at ja.burhanrashid52.photoeditor.PhotoSaverTask.doInBackground(PhotoSaverTask.java:70) at ja.burhanrashid52.photoeditor.PhotoSaverTask.doInBackground(PhotoSaverTask.java:23) at android.os.AsyncTask$3.call(AsyncTask.java:394) at java.util.concurrent.FutureTask.run(FutureTask.java:264)