Skip to content

Sync fork updates (incl. #1921/#1913) and Windows PDFium lifecycle fix#1933

Open
Dr-Usman wants to merge 15 commits into
DavBfr:masterfrom
Dr-Usman:master
Open

Sync fork updates (incl. #1921/#1913) and Windows PDFium lifecycle fix#1933
Dr-Usman wants to merge 15 commits into
DavBfr:masterfrom
Dr-Usman:master

Conversation

@Dr-Usman

Copy link
Copy Markdown

This PR proposes syncing the current fork branch (Dr-Usman:master) into upstream master.

Context:

  • This branch includes prior fork updates and is currently ahead of upstream.
  • It includes our Windows printing stability fix (post-print crash after Printing.layoutPdf).

Included upstream work already present in this fork:

  1. PR Fix threading issues in iOS and macOS printing plugin #1921
    Link: Fix threading issues in iOS and macOS printing plugin #1921
    Title: Fix threading issues in iOS and macOS printing plugin
    Summary:
  • Resolves thread/deadlock issues reported across platforms (macOS/iOS deadlocks and Windows property-related instability noted in the PR context).
  • Ensures printing logic is coordinated on the main thread with a runloop-driven approach so UI remains responsive while waiting for Dart PDF data.
  • Includes handling to avoid duplicated .pdf extension behavior.
  1. PR Fixed deadlock on macOS & added filtering of redundant layout requests #1913
    Link: Fixed deadlock on macOS & added filtering of redundant layout requests #1913
    Title: Fixed deadlock on macOS & added filtering of redundant layout requests
    Summary:
  • Replaces semaphore-based blocking with RunLoop polling to avoid deadlocks on newer Flutter merged-thread runtimes.
  • Adds timeout safety during PDF wait.
  • Adds layout parameter caching to avoid redundant onLayout calls.
  • Shares PrintJobs between plugin instances (multi-window safety) and uses randomized job ID start values.

Additional Windows fix included in this fork:

  • Move PDFium init/destroy to plugin lifetime in printing/windows/printing.cpp.
  • Remove per-job FPDF_DestroyLibrary() calls in printing/windows/print_job.cpp.
  • Fix classic PrintDlg cancel cleanup to release dialog handles safely (pd.hDC, pd.hDevMode, pd.hDevNames).

Why:

  • Prevents plugin-level PDFium teardown during app lifetime, which can crash other PDF viewers in host apps after printing on Windows.
  • Improves printing stability and cross-window correctness.

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