You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should be queuing tasks to the HistoryTraversalTaskSource instead of directly sending messages to the constellation when traversing the history via the history API.
Started looking into this and for sure, HistoryTraversalTaskSource does not implement TaskSource. What were the reasons or difficulties that prevented this?
The "session-history-traversal-queue" is a concept that I think would belong in the constellation, and is currently implemented indeed "by sending a message to the constellation", I think from there
The "history-traversal-task-source" is something that belongs in the script-thread like the other task sources and can be used to enqueue tasks on the script event-loop running inside a script-thread.
The main benefit of queuing a task in response to receiving a message from the constellation, as opposed to running the history changes directly in response to the message, is that queuing a task will ensure some sort of sane interleaved executing of the task in the context of all other history tasks that might have been(or will be) enqueued, which could actually be relevant for some edge cases(you can read more about this at https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-for-spec-authors, in this case the stuff happening in the constellation is done "in parallel", and the final changes to the history inside a script-thread is done "on the event-loop").
Additionally, we could also consider refactoring the code so as to more explicitly implement a session-history-event-loop inside the constellation(or maybe just add a comment with a link to the spec somewhere)
Activity
KiChjang commentedon May 12, 2016
Also part of #7959.
KiChjang commentedon May 12, 2016
@stjepang Did you say that you were working on this?
cbrewster commentedon Jan 27, 2017
We should be queuing tasks to the
HistoryTraversalTaskSourceinstead of directly sending messages to the constellation when traversing the history via the history API.https://html.spec.whatwg.org/multipage/browsers.html#traverse-the-history-by-a-delta
nox commentedon Oct 2, 2017
Was this done in the end?
jdm commentedon Oct 2, 2017
No.
vimpunk commentedon Nov 10, 2018
What is the status of this issue? I'd be interested in working on it but I might need some help.
vimpunk commentedon Nov 11, 2018
Started looking into this and for sure,
HistoryTraversalTaskSourcedoes not implementTaskSource. What were the reasons or difficulties that prevented this?vimpunk commentedon Nov 11, 2018
#21804 (comment)
Hmm, it looks like this may not be relevant after all?
gterzian commentedon Dec 1, 2018
@mandreyel I think there might still be something to do on this one.
HistoryTraversalTaskSourcewas recently fully implemented at 14bc8ab, and it's not actually used anywhere yet.Key is the difference between these two related concepts:
The "session-history-traversal-queue" is a concept that I think would belong in the constellation, and is currently implemented indeed "by sending a message to the constellation", I think from there
servo/components/script/dom/history.rs
Line 69 in 160f113
The "history-traversal-task-source" is something that belongs in the script-thread like the other task sources and can be used to enqueue tasks on the script event-loop running inside a script-thread.
This last part is currently not used.
What is happening instead is:
TraverseHistoryMsgis sent, corresponding to Step 1 of https://html.spec.whatwg.org/multipage/history.html#traverse-the-history-by-a-delta " append a task to this top-level browsing context's session history traversal queue".servo/components/constellation/constellation.rs
Line 2388 in 160f113
UpdateHistoryStateback to the script-thread.So, I think that what is missing is doing Step 5 of traverse-the-history-by-a-delta, inside a task from the "history-traversal-task-source".
The change that can be made is in 3 above(script-thread handling the message from constellation), we should instead of calling the history API directly, enqueue a task on the history traversal task source, and this task should consist of running the various substeps of Step 5 at https://html.spec.whatwg.org/multipage/history.html#traverse-the-history-by-a-delta
The main benefit of queuing a task in response to receiving a message from the constellation, as opposed to running the history changes directly in response to the message, is that queuing a task will ensure some sort of sane interleaved executing of the task in the context of all other history tasks that might have been(or will be) enqueued, which could actually be relevant for some edge cases(you can read more about this at https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-for-spec-authors, in this case the stuff happening in the constellation is done "in parallel", and the final changes to the history inside a script-thread is done "on the event-loop").
Other changes that might be necessary is implementing Step 4.1 of https://html.spec.whatwg.org/multipage/browsing-the-web.html#history-traversal "Remove any tasks queued by the history traversal task source that are associated with any Document objects in the top-level browsing context's document family."
Additionally, we could also consider refactoring the code so as to more explicitly implement a session-history-event-loop inside the constellation(or maybe just add a comment with a link to the spec somewhere)