Skip to content

Commit

Permalink
Merge pull request #629 from marp-team/stable-html-rendering
Browse files Browse the repository at this point in the history
Wait for next HTML animation frame when rendering
  • Loading branch information
yhatt authored Jan 15, 2025
2 parents a553d84 + 2e30e34 commit 7991dfc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
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

0 comments on commit 7991dfc

Please sign in to comment.