Bug 17761

Summary: window.onload fires before all subresources loaded
Product: WebKit Reporter: Oliver Hunt <oliver>
Component: Page LoadingAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: achristensen, ahmad.saleem792, ap, bfulgham, cdumez, hyatt, karlcow, rniwa, slewis, webkit-bug-importer
Priority: P2 Keywords: BrowserCompat, HasReduction, InRadar
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
URL: http://philip.html5.org/tests/canvas/suite/tests/index.2d.pattern.html
See Also: https://bugs.webkit.org/show_bug.cgi?id=15505
https://bugs.webkit.org/show_bug.cgi?id=33777

Oliver Hunt
Reported 2008-03-10 19:57:46 PDT
Some of the tests at http://philip.html5.org/tests/canvas/suite/tests/index.2d.pattern.html fail on the first load as they expect window.onload to fire after all their subresources -- the effect is especially noticeable in the 2nd test 2d.pattern.basic.image -- on the first load it fails, but if you reload the page it passes. The problem is that the code gets called in from window.onload and draws an image to the canvas, but the image has not loaded despite window.onload having fired.
Attachments
Oliver Hunt
Comment 1 2008-07-19 23:24:29 PDT
hyatt could you look at this? if only to record what needs to be fixed?
David Kilzer (:ddkilzer)
Comment 2 2008-12-02 10:17:23 PST
Duplicate of Bug 15505?
Ahmad Saleem
Comment 3 2022-07-22 04:04:29 PDT
I am able to reproduce this issue in Safari 15.6 on macOS 12.5, where loading the test case from the Comment 0 or URL field, there are some tests which fail on first load but when you refresh, they turn back to pass. While Firefox Nightly 104 and Chrome Canary 105 does not have any such case / issue. Thanks! Further, I haven't look into Comment 2 referring it to be potential duplicate. Thanks!
Alexey Proskuryakov
Comment 4 2022-07-22 11:18:29 PDT
This sounds really bad. As for whether this is a dupe of bug 15505, we need to analyze if the root cause is the came.
Radar WebKit Bug Importer
Comment 5 2022-07-22 11:18:41 PDT
Ahmad Saleem
Comment 6 2023-03-03 17:02:31 PST
I noticed a window.onload patches fix landed on Trunk so I tried to reproduce this again and can confirm, it is still reproducible on WebKit ToT (261177@main) using MiniBrowser and WK2 Private Window. It will fail some tests on first run and on second reload, it will pass them.
Karl Dubost
Comment 7 2024-05-09 00:24:31 PDT
> especially noticeable in the 2nd test 2d.pattern.basic.image -- on the first load it fails, but if you reload the page it passes. This specific test doesn't fail for me on the 3 browsers. There is a need for a better reduced test case to understand if this bug still occurs. The current page in https://philip.html5.org/tests/canvas/suite/tests/index.2d.pattern.html is a series of iframe elements. Some of these iframes are calling https://philip.html5.org/tests/canvas/suite/tests.js The window.onload is defined as ``` window.onload = function () { try { var canvas = document.getElementById('c'); var ctx = canvas.getContext('2d'); test(canvas, ctx); } catch (e) { _fail('Aborted with exception: ' + e.message); deferred = false; // cancel any deference } if (! deferred) endTest(); }; ``` The current tests failing (more likely) at first load, but green after reload are the tests toward the end of the page and it's randomly not the same set of tests.
Karl Dubost
Comment 8 2024-05-09 00:35:51 PDT
if I had document.readyState at the first line of test.js and inside window.onload = function () {} at the first line. All iframe calls have the sequence loading/complete even if they fail. So something is not matching here. I wonder if it's related to Bug 33777 And that would match the randomness of failures.
Note You need to log in before you can comment on or make changes to this bug.