(page: Page)
| 834 | // uncaught error that aborts the render. Skip in-flight and broken images; |
| 835 | // only force GPU upload for images that successfully loaded. |
| 836 | async function decodeAllImages(page: Page): Promise<void> { |
| 837 | await page.evaluate(async () => { |
| 838 | const imgs = Array.from(document.querySelectorAll("img")); |
| 839 | await Promise.all( |
| 840 | imgs.map((img) => { |
| 841 | const ie = img as HTMLImageElement; |
| 842 | if (typeof ie.decode !== "function") return Promise.resolve(); |
| 843 | // Skip still-loading images (in-flight decode() would hang) and |
| 844 | // broken images (decode() rejects, but pre-filtering is clearer |
| 845 | // than relying on the .catch). |
| 846 | if (!ie.complete || ie.naturalWidth === 0) return Promise.resolve(); |
| 847 | return ie.decode().catch(() => undefined); |
| 848 | }), |
| 849 | ); |
| 850 | }); |
| 851 | } |
| 852 | |
| 853 | async function applyVideoMetadataHints( |
| 854 | page: Page, |
no test coverage detected