burhanrashid52 / PhotoEditor

A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.
MIT License
4.12k stars 989 forks source link

Index out of bound #445

Closed hoangtuancntt closed 2 years ago

hoangtuancntt commented 2 years ago

Sometime I got an error Indexout of bound : index1 size 0 when save image. how do I solve this bug ?

lucianocheng commented 2 years ago

@hoangtuancntt do you have a stacktrace we can look at from the crash?

hoangtuancntt commented 2 years ago

@hoangtuancntt do you have a stacktrace we can look at from the crash?

Caused by java.lang.IndexOutOfBoundsException Index: 1, Size: 0 java.util.ArrayList.get (ArrayList.java:437)

android.view.View.draw (View.java:22080) com.smartwidgetlabs.notetogether.photoeditor.PhotoSaverTask.captureView (PhotoSaverTask.kt:137) com.smartwidgetlabs.notetogether.photoeditor.PhotoSaverTask.buildBitmap (PhotoSaverTask.kt:84) com.smartwidgetlabs.notetogether.photoeditor.PhotoSaverTask.saveImageInFile (PhotoSaverTask.kt:62) com.smartwidgetlabs.notetogether.photoeditor.PhotoSaverTask.doInBackground (PhotoSaverTask.kt:49) com.smartwidgetlabs.notetogether.photoeditor.PhotoSaverTask.doInBackground (PhotoSaverTask.kt:17) android.os.AsyncTask$3.call (AsyncTask.java:378)

lucianocheng commented 2 years ago

If this is happening sporadically, it may be because a user is adding / removing an element while the editor is saving.

Currently we export the image by reading directly from the View Tree on a AsyncTask background task. If the view tree is changed and not flushed, it can create an inconsistent state.

We don't have a good way to "copy" the view tree before exporting, and we don't want to run the export on the main (UI) thread, so we don't have a great solution for this at the moment.

A good workaround would be to disallow a user from changing anything in the editor while PhotoSaverTask is running.

Eventually we should probably not be reading from the View Tree for export. See #10

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 4 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 5 days with no activity.