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

[PlaygroundLogger] Better handle encoding of empty images and views. #27

Merged
merged 1 commit into from
Jul 6, 2018

Conversation

cwakamo
Copy link
Member

@cwakamo cwakamo commented Jul 6, 2018

If a NSView, NSImage, or UIImage was zero-sized (e.g. 0x0), PlaygroundLogger would fail to encode this because it couldn't get a bitmap representation for the image.
Instead, handle this case specially, and instead of failing, send zero bytes of PNG data. Xcode renders this as an empty image, which is the expectation for this case.
This commit includes tests that empty views and images on all platforms generate image representations which can be encoded without throwing any errors.

This is an improvement over the legacy PlaygroundLogger implementation, which would render these plus empty UIView instances as if they were the string "empty image".

This addresses rdar://problem/40207604.

…encode empty images.

If a `NSView`, `NSImage`, or `UIImage` was zero-sized (e.g. 0x0), PlaygroundLogger would fail to encode this because it couldn't get a bitmap representation for the image.
Instead, handle this case specially, and instead of failing, send zero bytes of PNG data. Xcode renders this as an empty image, which is the expectation for this case.
This commit includes tests that empty views and images on all platforms generate image representations which can be encoded without throwing any errors.

This is an improvement over the legacy PlaygroundLogger implementation, which would render these plus empty `UIView` instances as if they were the string "empty image".

This addresses <rdar://problem/40207604>.
@cwakamo cwakamo merged commit 5f820dd into apple:master Jul 6, 2018
@cwakamo cwakamo deleted the fix-empty-views-and-images branch July 6, 2018 17:42
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

Successfully merging this pull request may close these issues.

None yet

2 participants