Skip to content

[MBL-19887][Student] Fix PDF submission view ANR and blank pages#3615

Merged
kristofnemere merged 3 commits intomasterfrom
MBL-19887-fix-pdf-submission-view
Apr 2, 2026
Merged

[MBL-19887][Student] Fix PDF submission view ANR and blank pages#3615
kristofnemere merged 3 commits intomasterfrom
MBL-19887-fix-pdf-submission-view

Conversation

@kristofnemere
Copy link
Copy Markdown
Contributor

@kristofnemere kristofnemere commented Apr 1, 2026

Test plan:

  1. Open Canvas Student and navigate to a course with a PDF submission that has multiple attempts
  2. Switch between submission attempts — verify no ANR / freeze occurs
  3. Open a PDF submission that contains teacher stamp annotations — verify the stamps are visible and pages are not blank
  4. Open a PDF submission without stamp annotations — verify it loads normally
  5. Further details can be found in the Jira ticket

refs: MBL-19887
affects: Student
release note: Fixed an issue where viewing PDF submission feedback could freeze the app or show blank pages.

  • Follow-up e2e test ticket created or not needed
  • Tested in dark mode
  • Tested in light mode
  • Test in landscape mode and/or tablet
  • A11y checked
  • Approve from product

- 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]>
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 than onDocumentLoaded is the right timing fix to avoid the blank-page regression.
  • The canWrite() gate on enterAnnotationCreationMode() is a correctness improvement; read-only users should never have been placed in creation mode.
  • Removing appearanceGeneratorsJob / appearanceGeneratorsLoaded and the associated catch block simplifies the lifecycle considerably.

Issues found:

  • PdfSubmissionView.kt:485AnnotationType.TEXT as the stamp predicate is non-obvious; a one-line comment would help future maintainers (suggestion added inline).
  • PdfSubmissionView.kt:500 — The appearanceGeneratorsLoaded guard was removed; if loadAnnotations() ever runs more than once in a session the CustomStampAppearanceStreamGenerator could be registered multiple times. Worth confirming PSPDFKit de-dupes, or re-adding a local guard (comment added inline).

Comment thread libs/annotations/src/main/java/com/instructure/annotations/PdfSubmissionView.kt Outdated
…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]>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 1, 2026

🧪 Unit Test Results

✅ 📱 Student App

  • Tests: 1252 total, 0 failed, 0 skipped
  • Duration: 0.000s
  • Success Rate: 100%

✅ 📱 Teacher App

  • Tests: 373 total, 0 failed, 0 skipped
  • Duration: 28.651s
  • Success Rate: 100%

✅ 🌅 Horizon

  • Tests: 790 total, 0 failed, 0 skipped
  • Duration: 45.885s
  • Success Rate: 100%

✅ 📦 Submodules

  • Tests: 3345 total, 0 failed, 0 skipped
  • Duration: 52.904s
  • Success Rate: 100%

📊 Summary

  • Total Tests: 5760
  • Failed: 0
  • Skipped: 0
  • Status: ✅ All tests passed!

Last updated: Thu, 02 Apr 2026 08:26:16 GMT

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 1, 2026

📊 Code Coverage Report

✅ Student

  • PR Coverage: 42.65%
  • Master Coverage: 42.65%
  • Delta: +0.00%

✅ Teacher

  • PR Coverage: 25.37%
  • Master Coverage: 25.37%
  • Delta: +0.00%

✅ Pandautils

  • PR Coverage: 23.67%
  • Master Coverage: 23.67%
  • Delta: +0.00%

📈 Overall Average

  • PR Coverage: 30.56%
  • Master Coverage: 30.56%
  • Delta: +0.00%

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 1, 2026

Teacher Install Page

Comment thread libs/annotations/src/main/java/com/instructure/annotations/PdfSubmissionView.kt Outdated
Comment thread libs/annotations/src/main/java/com/instructure/annotations/PdfSubmissionView.kt Outdated
…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]>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 1, 2026

Student Install Page

Copy link
Copy Markdown
Contributor

@adamNagy56 adamNagy56 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA +1

@kristofnemere kristofnemere merged commit 9ecc1dc into master Apr 2, 2026
48 of 49 checks passed
@kristofnemere kristofnemere deleted the MBL-19887-fix-pdf-submission-view branch April 2, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants