Skip to content

Improve handling of load blocking events #41972

Closed
1 of 1 issue completed
Closed

Description

@TimvdLippe

Currently we don't fully implement load blocking events correctly. This is most noticeable with iframes, where the load of an iframe can fire too early. This leads to issues like #41807 (comment)

This is part of a broader the broader effort #31973 to fix iframe loading.

Right now, it is implemented as bool and the script_thread is eagerly called, despite multiple other factors that could also delay the load event.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    A-content/script
    on Jan 17, 2026
  2. jdm commented on Jan 17, 2026

    @jdm
    Member

    it is implemented as bool and the script_thread is eagerly called, despite multiple other factors that could also delay the load event.

    Can you be more specific about this? The LoadBlocker does a lot of heavy lifting to track those factors that delay the load event.

  3. TimvdLippe commented on Jan 17, 2026

    @TimvdLippe
    ContributorAuthor

    Yeah I did a large debugging session yesterday and still trying to figure out the pieces of the puzzle. But I believe

    if window_proxy.parent().is_some() {
    // https://html.spec.whatwg.org/multipage/#navigating-across-documents:delaying-load-events-mode-2
    // The user agent must take this nested browsing context
    // out of the delaying load events mode
    // when this navigation algorithm later matures.
    window_proxy.stop_delaying_load_events_mode();
    }
    is one of the culprits here. It immediately causes document.maybe_queue_document_completion() to run, despite it shouldn't run since we only finished parsing. I will update this issue when I know more concretely what's missing.

  4. jdm commented on Jan 17, 2026

    @jdm
    Member

    maybe_queue_document_completion is called maybe because it checks for outstanding loadblockers first in

    let not_ready_for_load = self.loader.borrow().is_blocked() ||

  5. TimvdLippe commented on Jan 17, 2026

    @TimvdLippe
    ContributorAuthor

    Sorry, yes it should be called, but it still thinks that it is ready to load. So the calling is correct, but the determining of not_ready_for_load isn't. Unfortunately it's quite tricky to determine why that's the case, so will need to do more debugging.

  6. jdm commented on Jan 17, 2026

    @jdm
    Member

    Yeah, it's believable that we're leaving the delaying mode earlier than we should be. For my own reference, the updated specification link for that is https://html.spec.whatwg.org/multipage/browsing-the-web.html#finalize-a-cross-document-navigation

  7. added a commit that references this issue on Feb 8, 2026
    bc63ef2
  8. TimvdLippe commented on Feb 8, 2026

    @TimvdLippe
    ContributorAuthor

    I figured out the issue: when we stop the delaying of the load event, we do that for the child proxy. However, per https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:delay-the-load-event the iframe element delays its owner document when its content navigable is in delaying load mode. Therefore, we should instead unblock its parent, not itself when we are no longer in delaying mode. Working on #42446 to figure out how to improve the situation here

  9. added 3 commits that reference this issue on Feb 8, 2026
    2fe629d
    656e441
    d0c2494
  10. TimvdLippe commented on Feb 9, 2026

    @TimvdLippe
    ContributorAuthor

    Okay, that PR is not sufficient on its own (the test still fails), but I think it unblocks the proper fix for the loadblocking of iframes.

  11. added 7 commits that reference this issue on Feb 9, 2026
    94e7698
    9e613a0
    cc607ea
    47e4f8b
    343dcfb
    160a6e6
    9d63917
  12. added a commit that references this issue on Feb 13, 2026
    e98cb76
  13. added a commit that references this issue on Mar 10, 2026
    c689d87
  14. added a commit that references this issue on Jun 27, 2026
    f613243
  15. added a commit that references this issue on Jun 28, 2026
    3daae41
  16. added a commit that references this issue on Jun 28, 2026
    656349b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/script

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions