Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Fix issue with screenshot captures (close #1872)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee committed Dec 8, 2020
1 parent 83247b5 commit ea13da4
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions app/bg/protocols/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,27 @@ export function setup () {
let data
if (asset === 'screenshot') {
data = await sitedata.get(url, 'screenshot', {dontExtractOrigin: true, normalizeUrl: true})
if (!data && !url.startsWith('dat:')) {
// try to fetch the screenshot
let p = activeCaptures[url]
if (!p) {
p = activeCaptures[url] = capturePage(url)
}
let nativeImg = await p
delete activeCaptures[url]
if (nativeImg) {
data = nativeImg.toDataURL()
await sitedata.set(url, 'screenshot', data, {dontExtractOrigin: true, normalizeUrl: true})
} else {
return serveJpg(path.join(__dirname, `./assets/img/default-screenshot.jpg`), DEFAULTS[asset], cb)
}

// DISABLED- seems to generate some pretty bad error behaviors on win7
// see https://github.com/beakerbrowser/beaker/issues/1872#issuecomment-739463243
// -prf
// if (!data && !url.startsWith('dat:')) {
// // try to fetch the screenshot
// let p = activeCaptures[url]
// if (!p) {
// p = activeCaptures[url] = capturePage(url)
// }
// let nativeImg = await p
// delete activeCaptures[url]
// if (nativeImg) {
// data = nativeImg.toDataURL()
// await sitedata.set(url, 'screenshot', data, {dontExtractOrigin: true, normalizeUrl: true})
// } else {
// return serveJpg(path.join(__dirname, `./assets/img/default-screenshot.jpg`), DEFAULTS[asset], cb)
// }
// }
if (!data) {
return serveJpg(path.join(__dirname, `./assets/img/default-screenshot.jpg`), DEFAULTS[asset], cb)
}
} else {
data = await sitedata.get(url, asset)
Expand Down

0 comments on commit ea13da4

Please sign in to comment.