pdf.js occasionally shows incorrect symbols until page is refreshed
Categories
(Firefox :: PDF Viewer, defect, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox78 | --- | verified |
People
(Reporter: handyman, Assigned: bobowen)
References
Details
Attachments
(8 files)
I don't have easy steps to reliably reproduce this but I probably see it on average after about 2-3 hours of PDF reading. The issue is that some symbols (I believe it is "some fonts") display incorrectly in the document I'm reading. Reloading the page immediately fixes the symbols. I've attached a screen shot of a page, before and after reloading the page. Check, for example, the second line, where Prt(A) was incorrectly rendered as \eta\phi(A). Some potentially useful points (I haven't confirmed if they are important):
- I am reading this document from a file on my hard drive, not the web.
- The document in the images is freely available here [1].
- I am currently on the 01-05-20 nightly build on Windows.
- I read a lot of PDFs. I'd say that this popped up, roughly, sometime in the last month.
- I have gfx.canvas.remote set to true. I don't know if this still on in nightly by default or not. This is part of Bob Owen's project to move 2D canvas operations out of the content process. I set that to true many months ago but, again, just recently started seeing this.
- Reloading the page seems to fix it every time. Other things, like changing tabs or switching window focus, seem to have no effect on the bug.
- I haven't seen the issue when just opening a document, but this may be a coincidence. I have always come across it after scrolling through the document.
[1] http://math.mit.edu/~dspivak/teaching/sp18/7Sketches.pdf
Reporter | ||
Comment 1•5 years ago
|
||
Reporter | ||
Comment 2•5 years ago
|
||
Comment 3•5 years ago
|
||
I haven't been able to reproduce locally yet. When this happens do you see any messages in the web console?
Reporter | ||
Comment 4•5 years ago
|
||
I didn't notice anything unusual in the console.
I was wrong about the frequency and severity of the issue. I now see this pretty frequently (still can take 1-2 hours to show though) and it can get to be very extreme. A few times, the page has been so garbled its essentially all an unintelligible, randomly strewn collection of font symbols where simple text should be. I'll try to get more useful pics and info. I have been focused on reading this particular pdf so this may be a coincidence but I haven't seen the bug in any of the other pdfs I've read.
Comment 5•5 years ago
|
||
Jonathan,
Do you know if gecko or windows ever unloads fonts after they are unused for awhile? I thought this may be a bug with pdf.js, since we will clear out fonts after inactivity. However, I've tried lowering that timeout, but I still am not able to reproduce the bug.
Reporter | ||
Comment 7•5 years ago
|
||
I haven't been using pdf.js much, which is why I've been silent, but I do still see this issue (most recently in the Feb 3rd nightly). I recently saw it again and have output from the web and browser consoles. I don't know if there is anything relevant in them but I'm attaching them. The only info I can add is that I think I'm seeing the problem happen fairly soon after navigating in the document with links (so, clicking page links in the pdf and/or using the browser back/forward buttons, again, to navigate inside of the document).
Reporter | ||
Comment 8•5 years ago
|
||
Reporter | ||
Comment 9•5 years ago
|
||
Reporter | ||
Comment 10•5 years ago
|
||
Adding this to underscore how bad the situation can be.
Reporter | ||
Comment 11•5 years ago
|
||
The bad image, repaired after reload.
Comment 12•5 years ago
|
||
- Do you have any web extensions enabled?
- I also noticed in the above log, the PDF url is a local file URL. Does this issue only happen when you're opening local "file:///" urls? Or does it happen for pdfs on regular URLs too?
Reporter | ||
Comment 13•5 years ago
|
||
Reporter | ||
Updated•5 years ago
|
Comment 14•5 years ago
|
||
If possible, could you try running Firefox in safe mode with extensions disabled for a bit and see if you still get the same problem? That would allow us to see one of the extensions is causing problems.
Comment 15•5 years ago
|
||
(In reply to Brendan Dahl [:bdahl] from comment #14)
If possible, could you try running Firefox in safe mode with extensions disabled for a bit and see if you still get the same problem? That would allow us to see one of the extensions is causing problems.
Another possible explanation is that this bug could be related to using gfx.canvas.remote = true
, since bug 1607630 comment 0 mentions using that.
Comment 16•5 years ago
|
||
I assume that means canvas drawing is happening in a separate process? I can imagine that might be an issue, because it means the font resource(s) that pdf.js extracts from the PDF and activates via @font-face will need to be sent over to the canvas drawing process, and then instantiated there as well; that may be happening asynchronously, such that the font isn't yet ready at the time of the first drawing operation that wants to use it. (And maybe the drawing process flushes its caches or even shuts down or something, if not used for a while?)
Updated•5 years ago
|
Reporter | ||
Comment 17•5 years ago
|
||
I've spent a good deal of time with this, running in a new profile and in safe mode. I did not reproduce the issue. I'm pretty sure that I would have, if the issue was present. There could be other explanations for this, like something unexpectedly different in my profile or that performance under my main profile is not nearly as good as with a fresh one (I tend to have a LOT of tabs open) but I'm leaning toward suspecting that gfx.canvas.remote=true
may not be innocent after all.
Assignee | ||
Comment 18•5 years ago
|
||
handyman - are you still able to reproduce this?
Comment 19•5 years ago
|
||
This is now affecting also the PDF.js test-suites, after they were recently updated to run on Firefox Nightly 77.
It's looks especially bad on Windows, which I've also confirmed locally, with fonts randomly failing to load correctly; please see e.g. these recent test results: https://github.com/mozilla/pdf.js/pull/11491#issuecomment-620761303
Assignee | ||
Comment 20•5 years ago
|
||
handyman - are you still able to reproduce this?(In reply to Jonas Jenwald [:Snuffleupagus] from comment #19)
This is now affecting also the PDF.js test-suites, after they were recently updated to run on Firefox Nightly 77.
It's looks especially bad on Windows, which I've also confirmed locally, with fonts randomly failing to load correctly; please see e.g. these recent test results: https://github.com/mozilla/pdf.js/pull/11491#issuecomment-620761303
Do these issues go away if you set the pref gfx.canvas.remote=false in your tests?
Comment 21•5 years ago
|
||
Do these issues go away if you set the pref gfx.canvas.remote=false in your tests?
Yes, as far as I can tell that fixes things.
Locally I first noticed this when bug 1547286 landed in Nightly (unfortunately I didn't have time to follow-up then), and I've also been seeing intermittent font corruption in PDF files during "normal" browser usage as well.
Assignee | ||
Comment 22•5 years ago
|
||
Thanks for testing that.
Do you have documents and STR, so that I can try and track this down?
Comment 23•5 years ago
|
||
(In reply to Bob Owen (:bobowen) from comment #22)
Thanks for testing that.
Do you have documents and STR, so that I can try and track this down?
Well the highly intermittent nature of this bug makes STR somewhat difficult to provide unfortunately.
Unless you're simply asking about how to run the PDF.js test-suite locally, in which case please see:
- https://github.com/mozilla/pdf.js#getting-the-code
This contains the necessary clone/setup instructions. - https://github.com/mozilla/pdf.js/wiki/Contributing#4-run-lint-and-testing
To summarize that page, after you've installed the necessary dependencies (see above) you- Generate reference images, with the
gulp makeref --noChrome
command. - Run the test-suites, using the
gulp test --noChrome
command.
- Generate reference images, with the
Assignee | ||
Comment 24•5 years ago
|
||
Thanks for the links.
I can reproduce this in the browsertest runs, but I don't seem to be able to reproduce when opening the PDFs in the actual browser.
Am I right in thinking that the PDFs are rendered slightly differently for the tests? (It looks that way from driver.js)
Also have you managed to reproduce ever when opening the PDF in the browser?
Comment 25•5 years ago
|
||
(In reply to Bob Owen (:bobowen) from comment #24)
Am I right in thinking that the PDFs are rendered slightly differently for the tests? (It looks that way from driver.js)
Sorry, different how? I'm not sure I understand exactly what you're asking here.
The point here is that everything worked fine previously, when e.g. the tests ran against Firefox 76, and there should absolutely not be any font-rendering failures when running gulp test --noChrome
directly after gulp makeref --noChrome
.
Also have you managed to reproduce ever when opening the PDF in the browser?
As mentioned previously it's highly intermittent, but the following is hopefully useful:
Reload http://mirrors.ctan.org/info/lshort/english/lshort.pdf over and over, in Firefox Nightly 77 on Windows 7, some type of font corruption happens at approximately every 25-50 reload.
Assignee | ||
Comment 26•5 years ago
|
||
(In reply to Jonas Jenwald [:Snuffleupagus] from comment #25)
(In reply to Bob Owen (:bobowen) from comment #24)
Am I right in thinking that the PDFs are rendered slightly differently for the tests? (It looks that way from driver.js)
Sorry, different how? I'm not sure I understand exactly what you're asking here.
The point here is that everything worked fine previously, when e.g. the tests ran against Firefox 76, and there should absolutely not be any font-rendering failures when running
gulp test --noChrome
directly aftergulp makeref --noChrome
.
I meant that test/driver.js has code for rendering and rasterizing the text (albeit using pdfjsLib), which might be slightly different to what happens in the viewer, not that the reference images and test images used different code.
I was just trying to grasp at something, because it seems to appear much more often in the tests.
Comment 27•5 years ago
|
||
(In reply to Bob Owen (:bobowen) from comment #26)
I meant that test/driver.js has code for rendering and rasterizing the text (albeit using pdfjsLib),
For the purpose of this bug, I think it's safe to ignore the text
tests. (The problem here rather seem to be that canvases lose loaded fonts intermittently, as far as I can tell.)
Please note the edited https://bugzilla.mozilla.org/show_bug.cgi?id=1607630#c25, where I've included the only STR that I can come up with that applies directly in the browser.
Assignee | ||
Comment 28•5 years ago
|
||
(In reply to Jonas Jenwald [:Snuffleupagus] from comment #25)
...
As mentioned previously it's highly intermittent, but the following is hopefully useful:
Reload http://mirrors.ctan.org/info/lshort/english/lshort.pdf over and over, in Firefox Nightly 77 on Windows 7, some type of font corruption happens at approximately every 25-50 reload.
Thanks, I can reproduce with that file, as you say it pretty rare, but hopefully it's enough to track down the problem.
Assignee | ||
Comment 29•5 years ago
|
||
I've found the problem.
The way we store UnscaledFonts in the recorder is flawed, meaning if a new font uses the same pointer as an old one, we will pick up the old font in the recording.
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 30•5 years ago
|
||
Assignee | ||
Comment 31•5 years ago
|
||
Comment 33•4 years ago
|
||
Comment 34•4 years ago
|
||
bugherder |
Comment 35•4 years ago
|
||
Reproduced the issue with Firefox Nightly 78.0a1 (2020-05-19) on Windows 10x64.
Verified as fixed with Firefox Nightly 78.0a1 (2020-05-20) on Windows 10 x84 and Windows 7 x86.
Updated•4 years ago
|
Description
•