From ca02a7f31d08fc38be54e5cbb1801b8dc156aa61 Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Tue, 21 Jan 2025 22:18:06 +0900 Subject: [PATCH] Debug JPEG conversion --- .circleci/config.yml | 1 + .github/workflows/test-win.yml | 1 + src/utils/jpeg.ts | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ad965b33..7365d027 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -100,6 +100,7 @@ commands: command: npm run test:coverage -- --ci --reporters=default --reporters=jest-junit <<#parameters.runInBand>>-i<><<^parameters.runInBand>>--maxWorkers=2<> environment: CHROME_DISABLE_GPU: 1 # Disable GPU acceleration to mitigate flaky tests + DEBUG: marp-cli:jpeg JEST_JUNIT_CLASSNAME: '{filepath}' JEST_JUNIT_OUTPUT_DIR: tmp/test-results MARP_TEST_CI: 1 diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml index 61ab1bc4..ea4bbf63 100644 --- a/.github/workflows/test-win.yml +++ b/.github/workflows/test-win.yml @@ -49,6 +49,7 @@ jobs: - name: Jest env: CHROME_DISABLE_GPU: 1 # Disable GPU acceleration to mitigate flaky tests + DEBUG: marp-cli:jpeg JEST_JUNIT_CLASSNAME: '{filepath}' JEST_JUNIT_OUTPUT_DIR: tmp/test-results MARP_TEST_CI: 1 diff --git a/src/utils/jpeg.ts b/src/utils/jpeg.ts index e1ead540..a982c998 100644 --- a/src/utils/jpeg.ts +++ b/src/utils/jpeg.ts @@ -1,5 +1,7 @@ +import dbg from 'debug' import { Browser } from '../browser/browser' -import { debug } from './debug' + +const debug = dbg('marp-cli:jpeg') export const png2jpegViaPuppeteer = async ( browser: Browser, @@ -13,6 +15,8 @@ export const png2jpegViaPuppeteer = async ( waitUntil: ['domcontentloaded', 'networkidle0'], }) + debug('Evaluating JavaScript to convert PNG to JPEG') + const jpegDataURL = await page.evaluate( async (pngUri, q, timeout) => { /* c8 ignore start */ @@ -52,6 +56,8 @@ export const png2jpegViaPuppeteer = async ( browser.timeout ) + debug('Evaluated JavaScript to convert PNG to JPEG') + if (!jpegDataURL.startsWith('data:image/jpeg;base64,')) throw new Error('Failed to convert PNG to JPEG')