Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dgp1130/wtr-raf-bug
https://github.com/dgp1130/wtr-raf-bug
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dgp1130/wtr-raf-bug
- Owner: dgp1130
- Created: 2023-12-25T06:50:16.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2023-12-25T07:12:43.000Z (11 months ago)
- Last Synced: 2024-10-06T02:01:47.017Z (about 1 month ago)
- Language: TypeScript
- Size: 449 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Web Test Runner `requestAnimationFrame` Bug
This is a minimal reproduction of a bug in Web Test Runner where
`requestAnimationFrame` does not trigger sometimes. It is highly inconsistent,
but the tests in this repo are flaky approximately 1/10 of the time.## Reproduction
The two tests are under [`src/`](./src/) and call `requestAnimationFrame` in a
specific way. Install the repository with:```shell
npm ci
```Run tests with:
```shell
npm test
```This will occasionally fail with a timeout which looks like:
```
dist/src/1.test.html:🚧 Browser logs:
start @ 1703487176420
requestAnimationFrame - 1 @ 1703487176420
callback - 1 @ 1703487176424
requestAnimationFrame - 3 @ 1703487176425
callback - 3 @ 1703487176426
requestAnimationFrame - 5 @ 1703487176427
callback - 5 @ 1703487176443
requestAnimationFrame - 7 @ 1703487176443
cancelAnimationFrame - 7 @ 1703487176443dist/src/2.test.html:
🚧 Browser logs:
start @ 1703487176427
requestAnimationFrame - 1 @ 1703487176428
callback - 1 @ 1703487176447
requestAnimationFrame - 3 @ 1703487176447❌ Error: FAILED: Timeout after 1000 milliseconds @ 1703487177428!
at src/timeout.ts:15:12
at async timeout (src/timeout.ts:7:9)
at dist/async%20http:/localhost:8000/src/2.test.js:3:1Chromium: |██████████████████████████████| 2/2 test files | 1 passed, 0 failed
```These logs came from [patching](./src/patch-raf.ts) `requestAnimationFrame` and
`cancelAnimationFrame` and observing their execution. Test 1 appears to execute
correctly, while test 2 fails waiting for `requestAnimationFrame`. Note that
a RAF call with handle `3` was scheduled but the callback was never invoked for
almost a full second. Longer timeouts do not fix this flaky behavior.## Fix
The fix is to create a new browser context for every page. See
`puppeteerLauncher` in
[`web-test-runner.config.mjs`](./web-test-runner.config.mjs)## Puppeteer
The `puppeteer` branch is able to replicate similar behavior by calling
Puppeteer directly and not using Web Test Runner at all. It does this by using
two pages from the same browser context.The fix is to create two different incognito contexts for the pages.