[MBL-19887][Student] Fix PDF submission view ANR and blank pages#3615
Merged
kristofnemere merged 3 commits intomasterfrom Apr 2, 2026
Merged
[MBL-19887][Student] Fix PDF submission view ANR and blank pages#3615kristofnemere merged 3 commits intomasterfrom
kristofnemere merged 3 commits intomasterfrom
Conversation
- Disable PSPDFKit autosave to prevent onStop() from blocking the main thread with a synchronous save, which caused an ANR when switching between submission attempts. - Guard enterAnnotationCreationMode() with a canWrite() check to avoid entering annotation mode on read-only sessions. - Move stamp appearance generator registration into loadAnnotations(), after the CanvaDocs network call completes. This eliminates a race condition where generators registered during onDocumentLoaded() could interrupt PSPDFKit's initial render and cause permanent blank pages. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
There was a problem hiding this comment.
Review Summary
This PR addresses two related ANR/blank-page issues in the PDF annotation view by (1) disabling PSPDFKit's autosave and (2) deferring stamp appearance generator registration to after the initial annotation network roundtrip. The changes are focused and well-reasoned.
Positive highlights:
autosaveEnabled(false)is a clean, targeted fix — the comment explaining the main-thread block is exactly the kind of "why" context that justifies an inline comment here.- Moving generator registration into
loadAnnotations()(post-network-call) rather thanonDocumentLoadedis the right timing fix to avoid the blank-page regression. - The
canWrite()gate onenterAnnotationCreationMode()is a correctness improvement; read-only users should never have been placed in creation mode. - Removing
appearanceGeneratorsJob/appearanceGeneratorsLoadedand the associatedcatchblock simplifies the lifecycle considerably.
Issues found:
-
PdfSubmissionView.kt:485—AnnotationType.TEXTas the stamp predicate is non-obvious; a one-line comment would help future maintainers (suggestion added inline). -
PdfSubmissionView.kt:500— TheappearanceGeneratorsLoadedguard was removed; ifloadAnnotations()ever runs more than once in a session theCustomStampAppearanceStreamGeneratorcould be registered multiple times. Worth confirming PSPDFKit de-dupes, or re-adding a local guard (comment added inline).
…d comment - Add stampAppearanceGeneratorsRegistered flag to prevent re-registering stamp appearance generators if loadAnnotations() is called more than once in a session (e.g. via updateAnnotations()). Flag is reset in onDocumentLoaded so a new document gets a fresh registration. - Add inline comment explaining that AnnotationType.TEXT is the CanvaDoc API type for stamp annotations. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Contributor
🧪 Unit Test Results✅ 📱 Student App
✅ 📱 Teacher App
✅ 🌅 Horizon
✅ 📦 Submodules
📊 Summary
Last updated: Thu, 02 Apr 2026 08:26:16 GMT |
Contributor
📊 Code Coverage Report✅ Student
✅ Teacher
✅ Pandautils
📈 Overall Average
|
Contributor
tamaskozmer
approved these changes
Apr 1, 2026
…n success - Move stamp appearance generator registration into its own registerStampAppearanceGenerators() suspend function to keep loadAnnotations() clean, matching the original code structure. - Set stampAppearanceGeneratorsRegistered = true only after successful registration so a failed attempt can be retried on the next call. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test plan:
refs: MBL-19887
affects: Student
release note: Fixed an issue where viewing PDF submission feedback could freeze the app or show blank pages.