This fixes a timeout in WPT's abort-in-initial-upgradeneeded.any.html
test. The timeout was a rare one, caused by idbfactory_open.any.html
leaving the second connection in the final test open, since support.js
only tracks the connection created by the first createdb call. By
leaving the connection open, the harness's deleteDatabase() call would
never take effect. This in turn meant that the upgradeneeded test would
fail an assertion on the number of databases. That assertion was also
uncaught by the harness, turning it into a timeout instead of a fail.
By closing the connections when a document is destroyed, we can ensure
that the connection doesn't leak over to the next test and cause the
exception to be thrown.
The timer nesting level throttling change (7577fd2a57) inadvertently
reverted the repeating timer optimization from 4d27e9aa5e, causing
setInterval() to use single-shot timers that re-arm after the callback
completes. This meant the next firing was scheduled relative to callback
completion rather than the previous fire time, causing drift
proportional to callback execution time.
For example, DiabloWeb's 50ms game loop with ~20ms of WASM work per
frame was only achieving 14 FPS (71ms intervals) instead of 20 FPS.
Fix this by using repeating Core::Timer for setInterval() again. The
repeating timer fires on schedule regardless of callback duration. On
re-arm, we update the callback (for nesting level changes) and the
interval (in case nesting level clamping kicks in), but don't restart
the timer since it's already running on the correct schedule.
This clamps the interval of repeating timers to 4ms after they have run
5 times. This prevents CPU spinning for `setInterval()` calls with low
timeouts.
Instead of creating a new single-shot timer every time a setInterval
timer reschedules itself, we now use a repeating Core::Timer internally.
This dramatically reduces timer drift, since the next timeout is now
based on when the timer fired, rather than when the timer callback
completed (which could take arbitrarily long since we run JS).
It's not perfect, but it's a huge improvement and allows us to play
DiabloWeb at full framerate (20 fps).
The User Timing, Resource Timing and Navigation Timing specifications
have not been updated to account for the queue method to also append to
the underlying performance buffer and it's method of checking it's
full.
This separates the functionality into a different function, with a flag
to indicate whether to use the custom full buffer logic or not.
Previously, they would stay open for the entire WebContent lifetime,
or until the server closed the connection. This was particularly
noticeable on collaborative websites/games such as
https://jigsawpuzzles.io/, where the user using Ladybird would stick
around even after they had navigated away.
Instead of always reporting a colno and lineno of zero try and use the
values from the Error object that may be provided, falling back to the
source location of the invocation if not provided. We can definitely
improve the reporting even more, but this is a start!
Also update this function to latest spec while we're in the area.
All global objects current need to be event targets so that they
can have events dispatched to them. This allows for removing of
verify_cast for these global objects.
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:
* JS::NonnullGCPtr -> GC::Ref
* JS::GCPtr -> GC::Ptr
* JS::HeapFunction -> GC::Function
* JS::CellImpl -> GC::Cell
* JS::Handle -> GC::Root