Screenshot example doesn't work on iOS Chrome

https://developer.playcanvas.com/en/tutorials/capturing-a-screenshot/
It looks like the good old Screenshot example project doesn’t work on iOS Chrome (or Firefox for that matter). Chrome does show a popup to download the file, but it doesn’t know what it’s downloading, it’s just a “document” without file format, and it doesn’t open as an image. iOS Safari works just fine.
Has anyone been able to find a workaround?

Hi @MrOliv,

Confirmed, tested on an iPhone X / iOS 14/ Chrome and I get the document named file that can’t be opened.

On Safari though it worked as expected, a screenshot.png was downloaded.

Not sure why that happens on Chrome, I’ll investigate and let you know.

1 Like

Hmm, this is a hard one, many people seem to have the same issue. I wasn’t able to find a solution online.

The closest I’ve come is to use a blob instead of a base64. That opens the screenshot on a new tab, not ideal but I think it’s a start.

    fetch(this.canvas.toDataURL("image/png"))
        .then(res => res.blob())
        .then(blob => window.open(URL.createObjectURL(blob)) );

If you aren’t able to solve this, I think the real workaround is to use a server to send the image data to and serve back a download url.

Thanks @Leonidas!