On Wed, Sep 11, 2024 at 1:49 PM Traian Captan <tca...@google.com> wrote:+ Mason and Philip who were asking about this issue, and Scot as FYIOn Wed, Aug 28, 2024 at 3:15 PM Traian Captan <tca...@google.com> wrote:Hi Daniel,Dominic thought it might be good to reach out to you regarding a proposed solution for fixing a set of bugs caused by not blocking window.print() while waiting for print resources to load.These bugs (like bug) came my way as a result of a recent CL I did: "Fix print-only object bitmap-image loading"The basic assertion of the bugs is that if `window.print()` is called we should block its return until the print dialog is closed.The way that resources are loaded for printing is via the `WillPrintSoon()` method which kicks off the async loading. This is called from `PrintRenderFrameHelper::RequestPrintPreview`, which checks if we need to wait for loading, and sets up a call back if waiting is necessary, then returns.Since we return while waiting for the print resources, `window.print()` returns too and does not block.One thing I tried to fix this issue is to create a new run loop, calling WillPrintSoon as a posted task and hoping that the response will be processed in the inner run loop which successfully blocks the window.print() call. However, while the WillPrintSoon task gets processed in the inner run loop the response does not get processed until we return to the main run loop after the print preview window closes.This turned out to be because of ScopedPagePauser in chrome_client.ccAfter commenting that out we achieve both blocking of the window.print() call and loading of print only resources. Does this seem like a reasonable approach?If it's problematic, do you have any advice on how to block this window.print() return while still processing the print only resource loads?Regards,Traian
--
You received this message because you are subscribed to the Google Groups "platform-architecture-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to platform-architect...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/platform-architecture-dev/CAF3XrKo02_aa80w5D9Jzb_mW7RvND%2BfJn2x7tborTjCjKkRVsA%40mail.gmail.com.
Thanks Dave!I'll leave the `ScopedPagePauser` in.
Do you have any suggestions on how to allow loading of the print only resources with the `ScopedPagePauser` on?Regards,Traian
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/platform-architecture-dev/CAHgVhZW4H2vVq20uMvzwVrCb2Jd%2BOVHBupjJw_1%2BeF3LMzm%2BsA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/platform-architecture-dev/CAHgVhZWEfdjwM7ExonPv2VwX1TmkgKuK8UOtLEKbgv%2BJyvreZQ%40mail.gmail.com.
All things considered, as of this moment my favored solution is:- Make window.open() return a Promise- Schedule the print dialog for a subsequent task if we need to load more stuff
It's been a while, but a few years ago I tried to change the printing code to remove that ScopedPagePauser and have PrintRenderFrameHelper take control, but that lead to https://crbug.com/40146790 and I had to revert. Not sure how much has changed since then, and if letting PrintRenderFrameHelper control pausing helps with the issue at hand.On Wed, Sep 18, 2024 at 1:43 PM Traian Captan <tca...@google.com> wrote:Hi All,Regarding what other vendors are doing, Safari blocks the `window.print()` call but does not load print only resources in time.Firefox is managing to load print only resources while blocking the current JS API `window.print()` call. This is most likely because they clone documents for printing.Currently Chrome loads print only resources but does not block `window.print()` if loading is occurring.I think it would be great if we could achieve something similar to Firefox for the current API, where we load these print only resources and block the `window.print()` at the same time.Instead of removing the `ScopedPagePauser` in `ChromeClient::Print`, how about we switch it to a `ScriptForbiddenScope` and fix the crashes in `BeforeCallEnteredCallback`?Regards,TraianOn Thu, Sep 12, 2024 at 7:13 PM Traian Captan <tca...@google.com> wrote:If we add a new promise-based API, what should we do for the old one? Not load print only resources in order to block, trading off rendering correctness?
Aside: Cloning documents for printing is on my birthday present wishlist
every year. :)
Is this something we're considering doing?