pdftron-flutter icon indicating copy to clipboard operation
pdftron-flutter copied to clipboard

`importAnnotations` works when called before `openDocument`

Open dcupidon opened this issue 2 years ago • 0 comments

Describe the bug On the branch export-annotations-bug, I created a two screen application: one is the Home Screen and the other renders the DocumentView. In the method used to control the PDFTron viewer, I included a call to importAnnotations before openDocument. I noticed the following when using the iOS plugin:

When navigating to the PDFTron viewer for the first time, the call to importAnnotations fails. After heading back to the Home Screen and then to the viewer, the call to importAnnotations works.

Steps to Reproduce the Problem

  1. Switch to the export-annotations-bug.
  2. Run the project on the iOS simulator.
  3. Switch to the PDFTron viewer page.
  4. Press the leading navigation button to go back to the Home Screen.
  5. Switch to the PDFTron viewer page.

Expected behavior The call to importAnnotations should always fail since it was done before openDocument finished.

Screenshots In both cases importAnnotations is importing a red box unto page 2.

Using the iOS plugin: https://user-images.githubusercontent.com/83605527/138756002-138da7f9-ec80-4c83-a014-1812fb72d7f3.mp4

Using the iOS widget: https://user-images.githubusercontent.com/83605527/138758478-2ff166b2-04fc-472a-b6a0-bccc3f03cb5d.mp4

Platform/Device Information

  • Platform: iOS
  • Device: iPod touch 7th Generation
  • OS: 14.4

Additional context Observations I made while debugging the application:

OS Widget Plugin
Android If importAnnotations is called before openDocument, a NullPointerException occurs in checkFunctionPrecondition. Same behaviour as the Android widget.
iOS If importAnnotations was called before openDocument, the property _documentLoaded was always equal to NO. After moving back to the Home Screen, a dealloc method is called when moving to the DocumentView. If importAnnotations is called before openDocument:
* On the first run, _tabbedDocumentViewController = nil so the import fails.
* On the second run, _documentLoaded = YES, so the import works. No dealloc method is called.

A "run" refers to moving from the Home Screen to the PDFTron viewer.

There is a bug in the application that limits the number of runs to two when using the plugin.

dcupidon avatar Oct 25 '21 19:10 dcupidon