Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for next HTML animation frame when rendering #629

Merged
merged 4 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Added

- Introduce parallelism for batch conversion: `--parallel` / `-P` ([#509](https://github.com/marp-team/marp-cli/issues/509), [#628](https://github.com/marp-team/marp-cli/pull/628))
- Introduce parallelism for batch conversion: `--parallel` / `-P` ([#509](https://github.com/marp-team/marp-cli/issues/509), [#628](https://github.com/marp-team/marp-cli/pull/628), [#629](https://github.com/marp-team/marp-cli/pull/629))

### Fixed

Expand Down
9 changes: 9 additions & 0 deletions src/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,15 @@ export class Converter {
await page.goto('data:text/html,', waitForOptions)
await page.setContent(baseFile.buffer!.toString(), waitForOptions)
}

// Wait for next frame (In parallel rendering, it may be needed to wait for the first rendering)
await page.evaluate(async () => {
/* c8 ignore start */
await new Promise<void>((resolve) =>
window.requestAnimationFrame(() => resolve())
)
/* c8 ignore end */
})
}

try {
Expand Down
4 changes: 2 additions & 2 deletions test/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ describe('Converter', () => {
expect(secondCall[1]).toBeInstanceOf(Buffer)
expect((secondCall[1] as Buffer).length).toBeLessThan(jpeg.length)
},
timeout
timeoutLarge
)
})

Expand Down Expand Up @@ -1315,7 +1315,7 @@ describe('Converter', () => {
expect(secondCall[1]).toBeInstanceOf(Buffer)
expect((secondCall[1] as Buffer).length).toBeLessThan(jpeg.length)
},
timeout
timeoutLarge
)
})
})
Expand Down