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.13k stars 992 forks source link

mPhotoEditor.saveAsBitmap() does not always hit `onBitmapReady()` nor `onFailure()` #195

Closed yusrilmr closed 4 years ago

yusrilmr commented 4 years ago

When I use OnSaveBitmap(), it will always work fine only when I put a breakpoint in PhotoEditor.saveAsBitmap, inside the AsyncTask.

Otherwise, sometimes, it does not trigger onBitmapReady() nor onFailure() at all. In the console, I also found this message:

I/Choreographer: Skipped 82 frames! The application may be doing too much work on its main thread.

There are some references that I also found: https://stackoverflow.com/questions/25882768/async-task-stops-working-works-when-debugging-with-break-points-android https://stackoverflow.com/questions/14678593/the-application-may-be-doing-too-much-work-on-its-main-thread

It seems, somehow, the system skips some heavy processing in certain situations.

My short term solution is to show a loading dialog and tell users "Rendering image, please wait. If it takes too long, please press cancel and re-edit the image again."

yusrilmr commented 4 years ago

It seems I have found the solution. I should have called mPhotoEditor.clearAllViews(); every time I load a new image to the PhotoEditorView. So far, I have tested the saving several times and it is always a success.

burhanrashid52 commented 4 years ago

Please close the issue if it's resolved.