kakashidinho / metalangle

MetalANGLE: OpenGL ES to Metal API translation layer
Other
461 stars 65 forks source link

Make `pauseOnWillResignActive` and `resumeOnDidBecomeActive` behavior match GLKit #56

Closed aab29 closed 3 years ago

aab29 commented 3 years ago

The paused, pauseOnWillResignActive, and resumeOnDidBecomeActive properties implemented in https://github.com/kakashidinho/metalangle/pull/41 work very well overall, but I noticed an issue with them in an app I work on. The app previously used a GLKViewController, which I've replaced with an MGLKViewController. After the replacement, some functionality that relied on pauseOnWillResignActive and resumeOnDidBecomeActive stopped working properly.

I did some investigation and figured out that a subtle difference in behavior is to blame. When an app displaying a GLKViewController resigns active state or becomes active, the view controller calls its setPaused: method. This is important because the app may override setPaused: to trigger other functionality. Currently MGLKViewController pauses and resumes itself in this situation without ever calling setPaused:, so this PR changes it to match the behavior of GLKit.

As mentioned in the comments of https://github.com/kakashidinho/metalangle/pull/41 , the isPaused property of GLKViewController is actually named paused. This PR changes the property name in MGLKViewController to match GLKit as well.

kakashidinho commented 3 years ago

Thanks for the PR! Let me do some testing first. btw, I'm not sure when the class is imported to swift, will paused property be translated to isPaused automatically? Since swift version of GLKViewController, this property is named isPaused. https://developer.apple.com/documentation/glkit/glkviewcontroller/1620712-ispaused

If it is not automatically translated, I think we should keep isPaused as alias of paused.

aab29 commented 3 years ago

Good catch! 😊 I'm not sure how this works in Swift yet, but since GLKit's declaration includes getter=isPaused, we should definitely make sure to match it.

kakashidinho commented 3 years ago

Good catch! 😊 I'm not sure how this works in Swift yet, but since GLKit's declaration includes getter=isPaused, we should definitely make sure to match it.

Interesting, I did test with swift. The property’s name did become “isPaused”.