Skip to content

Commit

Permalink
graceful failure?
Browse files Browse the repository at this point in the history
  • Loading branch information
elalish committed Oct 21, 2024
1 parent f70b47a commit 7a82c5c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
15 changes: 2 additions & 13 deletions packages/render-fidelity-tools/src/artifact-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {promises as fs} from 'fs';
import {mkdirp} from 'mkdirp';
import {join, resolve} from 'path';
import pngjs from 'pngjs';
import puppeteer, {Browser, Page} from 'puppeteer';
import puppeteer, {Browser} from 'puppeteer';

import {DEVICE_PIXEL_RATIO, Dimensions, FIDELITY_TEST_THRESHOLD, FidelityRegressionResults, GoldenConfig, ImageComparator, ImageComparisonAnalysis, ImageComparisonConfig, ScenarioConfig, toDecibel} from './common.js';
import {ConfigReader} from './config-reader.js';
Expand All @@ -34,7 +34,6 @@ export interface ScenarioRecord extends ScenarioConfig {
export class ArtifactCreator {
private[$configReader]: ConfigReader = new ConfigReader(this.config);
private browser: Browser|undefined = undefined;
private pagePromise: Promise<any>|undefined = undefined;

constructor(
protected config: ImageComparisonConfig, protected rootDirectory: string,
Expand All @@ -43,12 +42,6 @@ export class ArtifactCreator {
}

async close() {
if (this.pagePromise !== undefined) {
const page = await this.pagePromise;
await page.close();
this.pagePromise = undefined;
}

if (this.browser !== undefined) {
await this.browser.close();
this.browser = undefined;
Expand Down Expand Up @@ -301,15 +294,12 @@ export class ArtifactCreator {
return;
}


if (this.browser == undefined) {
console.log(`🚀 Launching browser`);
this.browser = await puppeteer.launch({headless: quiet});
this.pagePromise = this.browser.newPage();
}

const page = await this.pagePromise as Page;
this.pagePromise = undefined;
const page = await this.browser.newPage();

const url = `${this.baseUrl}?hide-ui&config=../../config.json&scenario=${
encodeURIComponent(scenarioName)}`;
Expand Down Expand Up @@ -390,7 +380,6 @@ export class ArtifactCreator {
await page.screenshot({path: outputPath, omitBackground: true});

page.close();
this.pagePromise = this.browser.newPage();

return screenshot;
}
Expand Down
5 changes: 1 addition & 4 deletions packages/render-fidelity-tools/test/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,7 @@
"dimensions": {
"height": 800,
"width": 550
},
"exclude": [
"model-viewer"
]
}
},
{
"name": "khronos-MosquitoInAmber",
Expand Down

0 comments on commit 7a82c5c

Please sign in to comment.