mozilla/pdf.js — pull request #5001 by CodingFabian (2014-06-24 22:30:20+00:00)
Title: Do not run cleanup while printing is ongoing.

During investigation of #4994 it became clear that one possible problem with fonts in print is that while printing is ongoing a font is removed and reloaded. If cleanup was set to a low number the problem disappeared.

the cleanup was scheduled when no page or thumbnail was rendered. Because printing uses a different mechanism, t could happen that printing occurs at the same time as cleanup. This is consistent with the observation that the error was reproducible after a few tries (most likely just hitting the 30 second mark).

The solution is to not run cleanup while printing is ongoing. Therefor a flag is set and renderHighestPriority() invoked before and after printing.

For completeness, this PR also nulls the timer when it triggers.