Closed Bug 1668230 Opened 4 years ago Closed 4 years ago

Print preview takes a bit of time to reload all content when changing the number of pages to print

Categories

(Core :: Print Preview, defect, P2)

defect

Tracking

()

RESOLVED WORKSFORME
Tracking Status
firefox82 --- fix-optional
firefox83 --- affected

People

(Reporter: csasca, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [print2020_v83][old-ui-])

Attachments

(2 files)

Affected versions

  • Firefox 82.0b5
  • Firefox 83.0a1

Affected platforms

  • Windows 10
  • macOS 10.13
  • Ubuntu 20.04

Steps to reproduce

  1. Launch Firefox
  2. Access this test pdf
  3. Access Print preview and select "Save to PDF" option
  4. Select Custom from "Pages"
  5. Edit any pages between 3 and 13.

Expected result

  • The preview is rendered quickly

Actual result

  • When editing a number, the page refreshes and the content takes a couple of seconds to load completely

Regression range

  • Will see for a regression if there is one.

Additional notes

  • The issue can be seen in the attachment
  • First time, when opening print preview, the document will be loaded nearly instantly, only by changing pages, will slow down a bit.

Suggested severity

  • S3
Has Regression Range: --- → no
Has STR: --- → yes
Severity: -- → S3
Priority: -- → P2
Whiteboard: [print2020_v82][old-ui-] → [print2020_v83][old-ui-]

I'm unable to reproduce locally. This happens quite quickly on my MacBook Pro (13", 3.5 GHz i7) in Nightly 83.

Emilio: Maybe we should get some profiles?

Flags: needinfo?(emilio)

It's very slow for me on my MacBook Pro 16". (Did you use the linked PDF and change the range from page 3 to 8, Sean?)

This is actually expected to be slow right now. Currently we still pass settings changes using an nsIPrintSettings object, and so far the only optimization we have implemented vs. the old implementation is to stop recloning the document every time a new settings object is passed. We do not yet compare the new settings object against the old settings object and try to be smart about the new reflow/layout work we do. There are a bunch of optimizations that could be made depending on which setting has changed. In the case of the page range changing, we should be able to avoid any reflow work in the common case where we have one page per sheet. However, it may be easier to do that if we fix bug 1661868 first (and doing it may make the work for bug 1631452 a bit harder?).

Daniel, maybe you also have some thoughts on this.

Flags: needinfo?(emilio) → needinfo?(dholbert)
Summary: Print preview takes a bit of time to reload all content when changing the number of pages to print → Try to avoid reflowing the print document when the page range changes

(In reply to Jonathan Watt [:jwatt] from comment #2)

It's very slow for me on my MacBook Pro 16". (Did you use the linked PDF and change the range from page 3 to 8, Sean?)

Yep, with the linked PDF and any combination of page ranges it's quite snappy (~0.5s) for me. Not sure why if it's mostly about reflow. Tried toggling WebRender but similar results.

The STR are fast for me as well (with Nightly on Linux, Dell XPS 15 9570). ~1s reaction time (And some of that 1s is an intentionally-imposed throttle, I think, to avoid reacting too quickly for each keypress when a user is typing/editing a multi-digit page number, for example.)

I definitely agree that we can & should avoid needless reflow for page-range changes, but it doesn't seem likely that that's the bottleneck here, given the variation in experiences. Could you capture a profile of the slowness & we can see if there might be something else involved?

(Meanwhile, I'll spin off a dedicated bug for avoiding needless reflow)

Flags: needinfo?(dholbert) → needinfo?(jwatt)
See Also: → 1668400

(In reply to Daniel Holbert [:dholbert] from comment #4)

(Meanwhile, I'll spin off a dedicated bug for avoiding needless reflow)

(Filed bug 1668400.)

(In reply to Daniel Holbert [:dholbert] from comment #4)

(Meanwhile, I'll spin off a dedicated bug for avoiding needless reflow)

In that case I'll revert the change I made to this bug's title.

Summary: Try to avoid reflowing the print document when the page range changes → Print preview takes a bit of time to reload all content when changing the number of pages to print

(In reply to Daniel Holbert [:dholbert] from comment #4)

Could you capture a profile of the slowness & we can see if there might be something else involved?

https://share.firefox.dev/2SaBm1j

Flags: needinfo?(jwatt)

Thanks! Yeah, reflow barely shows up in that profile. Looks like most of the jank there is from graphics/painting.

Theory: I think this might not have anything to do with page-ranges, and in fact it's just that the article has some complex-to-paint content on its later pages (like page 3). And if you edit the page range, that's just a quick-and-dirty way to instantly "scroll to" page 3. (If you scroll slowly, I think we pre-render content some distance ahead of you -- but if you edit the page range, we don't get a chance to do that.)

I can reproduce what I think is the same bug (~slow/noticeable incremental rendering) if I simply click and drag the scrollbar to the very end of the document, or to a far-away page. (Or if I click the scrollable area to focus it, and then hit the "end" key on my keyboard.)

jwatt, does this theory jive with your experience of this bug? (and do you see the same jank when forcing the scrollbar all the way to the end)?

Flags: needinfo?(jwatt)

Also, jwatt: could you test whether the redraw-jank is approximately-as-bad in these alternate STR?

(1) View the PDF ( http://www.dbsparks.com/research/html/SNRN02.pdf ), and be sure it's scrolled all the way to the top.
(2) Don't scroll down at all (that's cheating and prompts us to pre-render further along, which interferes with the results)
(3) Focus the page-selection box at the top left of our PDF.js viewer, and replace its "1" with "3" (to jump immediately to page 3)

When I do these steps, I can definitely see the graphics/text on Page 3 being incrementally drawn.

(If these STR are just-as-bad for you as the original STR, then this bug would seem to just be about PDF.js drawing kinda-slowly for this testcase.)

Attachment #9179633 - Attachment description: screencast of jumping directly to page 3 when viewing the PDF directly (no printing involved) → screencast of jumping directly to page 3 when viewing the PDF directly (no printing involved); similarly bad, I think?
Attachment #9179633 - Attachment filename: Screencast from 10-05-2020 08:52:16 AM.webm → screencast.webm

(In reply to Daniel Holbert [:dholbert] from comment #10)

(If these STR are just-as-bad for you as the original STR, then this bug would seem to just be about PDF.js drawing kinda-slowly for this testcase.)

Yeah, good call. They basically are. Let's close this then.

Catalin, if you try the steps from comment 10 and disagree with closing this, please reopen it.

Status: NEW → RESOLVED
Closed: 4 years ago
Flags: needinfo?(jwatt)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: