snapdom icon indicating copy to clipboard operation
snapdom copied to clipboard

In lower versions of iOS, only a portion of the screen can be captured

Open fu050409 opened this issue 1 year ago • 31 comments

Describe it simply:

This issue was reproduced in iOS 14, but it worked properly in iOS 18.

It was expected that we should produce a normal image, but in fact I got one that was of the same size as the expected image, but only the upper left corner of the content was captured. The same code was tested normally on other platforms.

~~Oh I hate iOS : (~~

Quick demo to reproduce

const res = await snapdom(componentRef.current, {
     quality: isIOS() ? 0.6 : 0.7,
     type: 'jpeg',
});

Anything else we should know?

I am using the latest version (v1.9.4) of SnapDOM. Perhaps it's a compatibility issue with a lower version of iOS.

I think the problem may stem from the fact that different versions of iOS handle scale differently?

Any response will be very appreciated.

fu050409 avatar Jul 21 '25 05:07 fu050409

I share the same feelings! 😀

You may try V1.9.6 but I'm almost sure you will get same results

tinchox5 avatar Jul 21 '25 09:07 tinchox5

Yes, there is a hack with scale on Safari. But I believe you may test with earlier snapdom versions maybe under 1.0.0. Because that fix easy introduced later

tinchox5 avatar Jul 21 '25 09:07 tinchox5

I share the same feelings! 😀

You may try V1.9.6 but I'm almost sure you will get same results

Yes, I've updated to v1.9.6, but the problem hasn't been solved. Do you have any ideas? html-to-image doesn't have this problem, but it often loses my pictures and doesn't work in some specific scenarios, lol.

fu050409 avatar Jul 21 '25 09:07 fu050409

Yes, there is a hack with scale on Safari.

I think so too. I also found compatibility issues with scale on caniuse.

But I believe you may test with earlier snapdom versions maybe under 1.0.0. Because that fix easy introduced later

Do you have a workaround?

fu050409 avatar Jul 21 '25 09:07 fu050409

If you find it works on an earlier version I can try to make a strong "hack"

tinchox5 avatar Jul 21 '25 10:07 tinchox5

@tinchox5 I tried to switch to snapdom v0.9.9, but there was no improvement except that it was slower than the latest version - I still got a screenshot with only the upper left corner. Should I try a lower version?

fu050409 avatar Jul 21 '25 11:07 fu050409

Yes please there is a version without the hack. But if you want, test with last version, just search isSafari() calls and comment the code

tinchox5 avatar Jul 21 '25 11:07 tinchox5

@tinchox5 Hi, I tried the earliest version (v0.9.1), but it seems there haven't been any more improvement.

I checked your source code, and I didn't pass in the scale parameter, which means snapdom should use the default parameter scale: 1. When the scale is 1, all the related logic seems not to have an impact. : (

fu050409 avatar Jul 21 '25 13:07 fu050409

I got some days off. But when I have time I Will make a new version without the scale hack so you can try it

tinchox5 avatar Jul 21 '25 13:07 tinchox5

Testing with chrome an safari on desktop, I am seeing the scale field indeed result in differing behavior. On chrome it seems to render the entire image still, whereas safari it cuts off the image. A way to output properly scaled on safari mac/iOS would be nice

Image Image

epurban avatar Jul 22 '25 14:07 epurban

is that with ios > 14?

tinchox5 avatar Jul 22 '25 15:07 tinchox5

@tinchox5 this is on a macbook running sequouia 15.3.2 and testing from different browsers.

epurban avatar Jul 22 '25 15:07 epurban

Thank you Safari is giving me a lot of unpleasant sorprises lately. But I will try to solve them

tinchox5 avatar Jul 22 '25 15:07 tinchox5

Just tested on iOS with chrome and safari browsers as well. Also seeing the same experience as safari on mac, where the image is scaled up but it is completely cut off. Thanks and hope we can get these resolved soon :)

epurban avatar Jul 22 '25 16:07 epurban

Yes, there will be not problems just I'm taking a holidays and I'm not always in front of a computer

tinchox5 avatar Jul 22 '25 16:07 tinchox5

Yes, there will be not problems just I'm taking a holidays and I'm not always in front of a computer

Never mind, I reproduced this issue on my MacBook too. I will also help you with this problem. There is too many compability issues on iOS, lol.

fu050409 avatar Jul 22 '25 16:07 fu050409

Please share the snapdom code detailing scale and export format. I believe there is an issue when exporting scale > 1 and bitmaps format like jpg.

tinchox5 avatar Jul 26 '25 11:07 tinchox5

Solved! My bad.

tinchox5 avatar Jul 26 '25 15:07 tinchox5

Solved! My bad.

Could you please create a new release so I can have a test? :D

fu050409 avatar Jul 27 '25 03:07 fu050409

Changes are already in main branch. You can clone the repo, run npm install and then npm run compile.

Or wait some hours and I will make a pre-release version

tinchox5 avatar Jul 27 '25 06:07 tinchox5