fix: resolve blank page and timeout errors on large PDF exports#174
Closed
ThisIs-Developer wants to merge 4 commits into
Closed
fix: resolve blank page and timeout errors on large PDF exports#174ThisIs-Developer wants to merge 4 commits into
ThisIs-Developer wants to merge 4 commits into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Deploying markdown-viewer with
|
| Latest commit: |
0f8192f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://73cbf0e9.markdown-viewer.pages.dev |
| Branch Preview URL: | https://fix-large-pdf-export-blank-p.markdown-viewer.pages.dev |
Deploying markdownviewer with
|
| Latest commit: |
0f8192f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://356fefe1.markdownviewer.pages.dev |
| Branch Preview URL: | https://fix-large-pdf-export-blank-p.markdownviewer.pages.dev |
… for large documents
7962822 to
8ca2cfc
Compare
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.
Summary
This PR addresses the critical issue where exporting large markdown documents (12K+ characters) to PDF results in blank/empty pages or causes browser tabs to freeze and timeout.
Root Cause
toDataURL('image/png')for page slicing. PNG's deflate algorithm runs single-threaded on the main JS execution thread, taking ~3.2 seconds per page. For large documents (30+ pages), this blocked the event loop for over 90 seconds, causing browser timeouts or unresponsive script warnings.Proposed Changes
0.95quality). Browser-native JPEG encoding completes in milliseconds, eliminating the single-threaded CPU compression bottleneck and reducing output PDF size by ~70% without visual degradation.requestAnimationFrame, preventing the main thread from locking up and keeping progress bar animations fluid.desktop-app/resources/js/script.jsviaprepare.js.Performance Results
Regression Verification