packages.flutter icon indicating copy to clipboard operation
packages.flutter copied to clipboard

Rendering on Android blocks UI

Open SEGVeenstra opened this issue 2 years ago • 3 comments

Describe the bug Using PdfPage.render on Android blocks the UI.

To Reproduce Steps to reproduce the behavior:

  1. Add a PdfView to your UI
  2. add a custom renderer (the bigger the image, the better you'll see the behavior)

Expected behavior Smooth working UI/ UI not being blocked

Screenshots iOS (Good) Simulator Screen Recording - iPhone 14 Pro - 2023-12-11 at 09 49 49 Android(Bad) Screenrecorder-2023-12-11-09-51-51-527

Smartphone (please complete the following information):

  • Device: POCO X3 PRO
  • OS: Android
  • Version: 11

Additional context Add any other context about the problem here.

SEGVeenstra avatar Dec 11 '23 13:12 SEGVeenstra

My Kotlin is awefull so I asked ChatGPT to "Fix the code in a way it wouldn't block the UI" and it added coroutines. Not it's no longer blocking the UI.

I've only done this for the render and openDocumentFile just to test so it might need to be added to others as well?

Screenrecorder-2023-12-12-13-38-14-802

SEGVeenstra avatar Dec 12 '23 12:12 SEGVeenstra

@SEGVeenstra could you share the code for your fix and/or open a pull request with the changes?

rpekarek-tc avatar Jan 08 '24 15:01 rpekarek-tc

@SEGVeenstra could you share the code for your fix and/or open a pull request with the changes?

Like I mentioned, I'm not into Kotlin, but this has the changes I got from ChatGPT:

Code

SEGVeenstra avatar Jan 08 '24 15:01 SEGVeenstra