Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Replace deprecated GLKView with MTKView #282

Closed
wants to merge 1 commit into from
Closed

Replace deprecated GLKView with MTKView #282

wants to merge 1 commit into from

Conversation

woxtu
Copy link
Contributor

@woxtu woxtu commented Dec 7, 2020

Closes #268

What It Does

This PR replaces GLKView with MTKView to fix warnings related to GLKView:

  • 'GLKView' is deprecated: first deprecated in iOS 12.0 - OpenGLES API deprecated

How to Test

Add a blur annotation to your screenshot.

Notes

I added a workaround to resolve the issue of image flipping vertically when run in the simulator. See this article for reference.

@mliberatore
Copy link
Contributor

Thanks, @woxtu!

I’m seeing a slight regression with the Metal implementation. The contents within the blurred rectangle are offset quite a bit from the area that the rectangle covers. The Before screenshot shows what’s on master, that the contents of the rectangle more closely match the positioning of the content beneath it.

Before

IMG_7347E3BC327A-1

After

File|

Copy link
Contributor

@mliberatore mliberatore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for addressing the comment above.

@woxtu
Copy link
Contributor Author

woxtu commented Dec 12, 2020

@mliberatore
Thank you for your testing.
Unfortunately, I cannot reproduce the offset. Could you tell me about your environment?
FYI, I tested in the simulator (iOS 14.2) and iPhone 8 (iOS 13.5.1) using Xcode 12.2.

@mliberatore
Copy link
Contributor

Hi @woxtu. I’m running Xcode 12.2 (12B45b). I just ran a few more tests on different devices, and the offset is occurring for me on 2 of the 3 test iPhones that I have handy. It occurs on:

  • iPhone 12 mini – iOS 14.2.1 (18B121)
  • iPhone 6 Plus – iOS 12.4.8 (16G201)

It does not occur on:

  • iPhone 7 – iOS 14.0.1 (18A393)

I also tried on the iPhone 12 Mini simulator this morning, and couldn’t reproduce it there. Between the devices that you and I have tried, my hunch is that this is only happening on screens with 3x scale, and only on hardware devices, not simulators.

Here’s a screenshot of it on the 6 Plus, where it appears as though the offset is even greater:

IMG_0C0C6D4849E5-1

Also, turning off the blur entirely just returning the image from BlurAnnotation.blurredImage makes it a bit easier to see the offset:

IMG_ED87BAC7700F-1

@mliberatore
Copy link
Contributor

I think this might be the answer to the issue, as the problem seems to be similar: https://stackoverflow.com/a/56334696

It’d warrant more testing, but for example, we could call:

MTKView?.drawableSize = annotation?.image.extent.size ?? .zero

from annotation’s didSet, after MTKView?.layer.mask = layer.

@mliberatore
Copy link
Contributor

Hi @woxtu! I just wanted to check in on this pull request. Please let us know if you’d like to make the changes discussed above, otherwise we’d be happy to make them on our end soon.

@Kondamon
Copy link

Kondamon commented Aug 6, 2021

Hello @woxtu, could you resolve the offset or are there any updates related to this issue? Thank you!

@mliberatore mliberatore added this to the iOS 15 Release milestone Aug 25, 2021
@jbouaziz
Copy link

@woxtu would that PR add support for Mac Catalyst ? GLKit is not available but Metal Kit is.

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

Successfully merging this pull request may close these issues.

'GLKView' is deprecated: first deprecated in iOS 12.0
5 participants