lohanidamodar / pdf_viewer

A flutter plugin for handling PDF files. Works on both Android & iOS
https://pub.dev/packages/advance_pdf_viewer
BSD 3-Clause "New" or "Revised" License
61 stars 143 forks source link

Memory leak #84

Open omkartralsawala opened 2 years ago

omkartralsawala commented 2 years ago

I am using advance_pdf_viewer in my flutter app and am getting the following error regarding a memory leak

Please look into it!!

W/System (12561): A resource failed to call close. ════════ Exception caught by image resource service ════════════════════════════ The following assertion was thrown by an image listener: setState() called after dispose(): _PDFPageState#a30fd(lifecycle state: defunct, not mounted)

This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.

The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().

When the exception was thrown, this was the stack

0 State.setState.

1 State.setState

2 _PDFPageState._repaint.

3 ImageStreamCompleter.setImage

4 MultiFrameImageStreamCompleter._emitFrame

... ════════════════════════════════════════════════════════════════════════════════