UIMenuController is leaking out blur background. Discussed at WWDC 2016. Hard to reproduce. Always sticks in the eye.

Number:rdar://28275291 Date Originated:13-Sep-2016 09:51 AM
Status:Open Resolved:
Product:UIKit Product Version:iOS 10GM
Classification:UI Reproducible:Always
Peter Steinberger13-Sep-2016 09:51 AM


UIMenuController sometimes has a bug where the mask on the blur background is cleared, making it look like the blur "leaks out" of the shape, which looks quite silly. This has been reported to us numerous times, and I always (wrongfully) assumed that this must be widespread and surely will be fixed. It was extremely hard to figure out how to trigger this reproducibly.

It's been bugging us in PSPDFKit since iOS 7 but without a clear way to repro, we dismissed it as "sometimes" and "random bug" and largely ignored the ticket.

It really popped up again because we're finally doing this PDF Viewer app (yay!) and quite a few people reported this bug again. So - finally spent time on it. I know, timing for iOS 10 is a but unfortunate, but since this seems to be a purely visual bug you might be able to fix it without the AppCompat team shouting at you.

We did discuss this in the UIKit labs at WWDC 2016 but didn't get much interest from the maintainer of this component to fix - potentially because you were swamped with other issues. Well - here I am again, trying once more :)

Steps to Reproduce:
Download our PDF Viewer app: pspdfkit.com/viewer

select text
set any annotation via the toolbar
select the annotation again
"Type.." to change the annotation so something different
Now the toolbar is not transparent or has weird shadows
Sometimes the shadow is noticable, but sometimes it's just one corner that is not transparent

Alternatively - you can also download a demo of PSPDFKit (attaching latest stable here), open the PSPDFCatalog, select a PDF (e.g. just choose first entry) and the follow the steps above. The flow is the same.

I'm trying to come up with an isolated example, but so far did not succeed.

See the flow.gif for a visual walk-through. Also notice how the animation seems broken once the blur leaks out.

Expected Results:
The blur background should stay behind the shape to keep a consistent UI component.

Actual Results:
The blur background loses its mask and the control looks weird - see screenshot.

iOS 10 GM

This is in the codebase since iOS 7.

iPhone 6s Plus (but really, any device is affected also Simulator)


So, after hours of trying out stuff we FOUND OUT HOW TO TRIGGER IT :)

Setting the target rect when the menu controller is already visible results in the leaking blur background. We work around this by (sorry) swizzling the setTargetRect:inView: method and only call it when the menu controller is not visible.

Sample: https://github.com/PSPDFKit-labs/radar.apple.com/tree/master/28275291%20-%20UIMenuControllerBlur

Image: https://cl.ly/1H280Y273W0h Flow: https://cl.ly/1m2y1Z3u0f0Y

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!