pdftron-flutter
pdftron-flutter copied to clipboard
`importAnnotations` works when called before `openDocument`
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
- Switch to the
export-annotations-bug
. - Run the project on the iOS simulator.
- Switch to the PDFTron viewer page.
- Press the leading navigation button to go back to the Home Screen.
- 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.