Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with snapshots containing "complicated" transparent images #120

Open
mime29 opened this issue Feb 14, 2020 · 2 comments
Open

Issues with snapshots containing "complicated" transparent images #120

mime29 opened this issue Feb 14, 2020 · 2 comments

Comments

@mime29
Copy link

mime29 commented Feb 14, 2020

In a project I'm working on, we have lots of issues with "glitches" in captures images when the transparent images contain shadows or text with rounded fonts.

It results in image comparison failure and diff images with those "glitches" that are very small differences.

I made a fix that seems to solve the issue using swizzling so far. I can't make a PR on the concerned files on this repository at this point because it might impact other projects using this library.
If anybody has an idea how we can make it configurable, that would be good.

The fix:

In + (UIImage *)fb_imageForLayer:(CALayer *)layer and + (UIImage *)fb_imageForView:(UIView *)view from the file UIImage+Snapshot.m I changed the context to capture only opaque images by changing the following line:

from

UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0); 

to

UIGraphicsBeginImageContextWithOptions(bounds.size, YES, 0);

Note: I went in OpenRadar to try to find a bug related to this but didn't find any screenshot glitches posts. As this issue could maybe come from some compression algorithm that I'm not aware of, I'm not filing a radar yet.

@zablaetna
Copy link

I've been noticing this a lot lately, too. Image Diffs that look completely blank.

@tinder-maxwellelliott
Copy link
Contributor

In a project I'm working on, we have lots of issues with "glitches" in captures images when the transparent images contain shadows or text with rounded fonts.

It results in image comparison failure and diff images with those "glitches" that are very small differences.

I made a fix that seems to solve the issue using swizzling so far. I can't make a PR on the concerned files on this repository at this point because it might impact other projects using this library.
If anybody has an idea how we can make it configurable, that would be good.

The fix:

In + (UIImage *)fb_imageForLayer:(CALayer *)layer and + (UIImage *)fb_imageForView:(UIView *)view from the file UIImage+Snapshot.m I changed the context to capture only opaque images by changing the following line:

from

UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0); 

to

UIGraphicsBeginImageContextWithOptions(bounds.size, YES, 0);

Note: I went in OpenRadar to try to find a bug related to this but didn't find any screenshot glitches posts. As this issue could maybe come from some compression algorithm that I'm not aware of, I'm not filing a radar yet.

Can you simply share a patch file of the necessary changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants