Skip to content

Treat "fire an event" and script execution blocks as "tasks" if outside document-associated task#37

Merged
noamr merged 7 commits intomainfrom
pseudo-task
Apr 16, 2026
Merged

Treat "fire an event" and script execution blocks as "tasks" if outside document-associated task#37
noamr merged 7 commits intomainfrom
pseudo-task

Conversation

@noamr
Copy link
Copy Markdown
Collaborator

@noamr noamr commented Apr 14, 2026

Some operations, like UI events, are not defined in terms of tasks. When those operations invoke a script or fire an event, treat the script or event firing timeframe as a "task" for the purposes of LoAF reporting.

Currently, those should have a document associated to them with the "implied document" concept, however that is not interoperable and deprecated.

Together with whatwg/dom#1462
Closes #36


Preview | Diff

…ocument-associated task

Some operations, like UI events, are not defined in terms of tasks.
When those operations invoke a script or fire an event, treat the script or event firing
timeframe as a "task" for the purposes of LoAF reporting.

Closes #36
@noamr noamr requested a review from yoavweiss April 14, 2026 15:00
Copy link
Copy Markdown
Contributor

@yoavweiss yoavweiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions/comments. Also the title is slightly botched and has a double negative that makes it confusing..

Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
@yoavweiss
Copy link
Copy Markdown
Contributor

One more high-level question - why not rely on the implied document?

@noamr noamr changed the title Specify processing model for scripts/events that don't run inside a task that doesn't have anassociated document Specify processing model for scripts/events that don't run inside a task that doesn't have an associated document Apr 16, 2026
@noamr
Copy link
Copy Markdown
Collaborator Author

noamr commented Apr 16, 2026

One more high-level question - why not rely on the implied document?

That concept is deprecated and hopefully will be removed from the standard at some point.

@noamr noamr changed the title Specify processing model for scripts/events that don't run inside a task that doesn't have an associated document Treat "fire an event" and script execution blocks as "tasks" if not inside a document-associated task Apr 16, 2026
@noamr
Copy link
Copy Markdown
Collaborator Author

noamr commented Apr 16, 2026

A few questions/comments. Also the title is slightly botched and has a double negative that makes it confusing..

Fixed the issues and the title.

@noamr noamr changed the title Treat "fire an event" and script execution blocks as "tasks" if not inside a document-associated task Treat "fire an event" and script execution blocks as "tasks" if outside document-associated task Apr 16, 2026
Comment thread index.bs Outdated
Comment thread index.bs Outdated
[=list/append=] |scriptTimingInfo| to |frameTimingInfo|'s [=frame timing info/scripts=].
1. If |frameTimingInfo| is [=frame timing info/script initiated=], then [=record task end time=] given |endTime| and |document|.

Note: For event listeners, the task ends at the end of the [=fire an event=] algorithm rather than at the end of a single listener's execution.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not immediately obvious to me how this is set for event listeners. Can you point at the relevant algorithm?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the [=fire an event=] algorithm I'm already pointing to :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded a bit, is this better?

Comment thread index.bs
<div algorithm="Record if needed">
To <dfn export>start recording task time if needed</dfn> given an [=environment settings object=] |settingsObject|:

Note: this is called from the [=fire an event=] algorithm and the [=create script entry point=] algorithm.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, "fire an event" doesn't directly call this, but indirectly calls "create script entry point", which calls this. It might be good to rephrase

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see the confusion. This needs a corresponding DOM PR. I'll post one and link them.

Copy link
Copy Markdown
Contributor

@yoavweiss yoavweiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % note comment

noamr added a commit to whatwg/dom that referenced this pull request Apr 16, 2026
Together with w3c/long-animation-frames#37

This allows clustering a "fire an event" timeframe in terms of
frame timing monitoring, as opposed to relying on an "implicit document", which
is a deprecated and non-interoperable term.

The implication of this is that if this event firing schedules a render that ends up
as a long animation frame, the whole event firing duration would be counted towards this
performance entry, regardless of "tasks".

See w3c/long-animation-frames#36
@noamr noamr merged commit 088c2e1 into main Apr 16, 2026
2 checks passed
github-actions Bot added a commit that referenced this pull request Apr 16, 2026
SHA: 088c2e1
Reason: push, by noamr

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specify how LoAF behaves for tasks without a Document

2 participants