[Webkit-unassigned] [Bug 251887] REGRESSION(253223 at main): PDF.js viewer fails to load PDF: [Error] TypeError: null is not an object (evaluating 'PDFViewerApplication.eventBus.on')

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Feb 16 15:00:07 PST 2023


https://bugs.webkit.org/show_bug.cgi?id=251887

--- Comment #9 from Tim Nguyen (:ntim) <ntim at apple.com> ---
(In reply to Michael Catanzaro from comment #8)
> Created attachment 465033 [details]
> Screenshot providing the missing variable does exist
> 
> So if I select viewer.html in the bottom-right corner of the web inspector,
> then attempt to evaluate PDFViewerApplication.eventBus.on, it does work. So
> I assume PDFViewerApplication gets created at the wrong time, after the
> content script runs.
> 
> I don't know how to fix this. Hi Tim, how amenable would you be to a revert
> for now?

I'd prefer to not revert, there's a bunch of commits on top, and it's also what allows the custom context menu to work (which WebKitGTK might have as well fwiw).

It sounds like there is some kind of race condition where the content script is injected before `PDFViewerApplication.eventBus` is initialized from the error you're seeing. Figuring out why that is the case would be nice.

The content-script.js file is injected when the iframe loads: https://searchfox.org/wubkat/rev/cccd00688012d25c2cac5d6aa11b86f937927770/Source/WebCore/html/PDFDocument.cpp#117

Something you could try is:
```
        if (PDFViewerApplication.eventBus) {
            PDFViewerApplication.eventBus.on("pagesinit", () => {
                this.autoResize();
            });
        } else
            this.autoResize();
```

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20230216/01a2fffb/attachment-0001.htm>


More information about the webkit-unassigned mailing list