Replaces #1501, which I guess I can't reopen, for Reasons. See that PR for comments.
Asynchronous inject can result in race conditions where there were previously not any. (Well, maybe this isn't what you would think of of as a race condition? Anyway, by the time the code runs, the target may not be attached to the DOM any more, e.g. if you've scrolled past it.)
Presuming we don't want to pursue instant injection, at least at the moment, this should be fairly easy to handle. I would probably just decline to run unburyTimelineObject and never resolve the inject promise, at first thought? That would stall the function awaiting the inject forever rather than making it have to put a conditional on the result. Not sure how garbage collection works in that case, though; we don't want to leave DOM elements un-GC'd because they have event listeners pending.
One way to prevent the console being filled with errors whenever you scroll any timeline with the current MV3 branch, without needing to adjust every location we call timelineObject(), is to respond to injection requests for no-longer-attached-by-the-time-we-process elements with a promise that is neither resolved nor rejected. One would otherwise have to add a conditional early return to each invocation of the function.
This diff is very nice, but it does leave around some mutation observers that will never get triggered. Probably fine?
Testing steps
Scroll the dashboard quickly and confirm that there are no errors in the console similar to those experienced in the branch without this PR.
Replaces #1501, which I guess I can't reopen, for Reasons. See that PR for comments.
Description
One way to prevent the console being filled with errors whenever you scroll any timeline with the current MV3 branch, without needing to adjust every location we call
timelineObject()
, is to respond to injection requests for no-longer-attached-by-the-time-we-process elements with a promise that is neither resolved nor rejected. One would otherwise have to add a conditional early return to each invocation of the function.This diff is very nice, but it does leave around some mutation observers that will never get triggered. Probably fine?
Testing steps