SRGSSR / srgmediaplayer-apple

An advanced media player library, simple and reliable
MIT License
158 stars 33 forks source link

iOS 14 picture in picture leak #93

Closed defagos closed 3 years ago

defagos commented 3 years ago

iOS 14 contains a regression due to changes required to make PiP available on iPhone. I first noticed this issue in Xcode 12 early beta versions, but I knew Apple was working on the feature so I tested each beta version to check for improvements.

I reported the issue end of August (FB8561088) since nothing improved. Now that iOS 14 is released we need an emergency fix.

defagos commented 3 years ago

We can workaround the issue by displaying a dummy AVPlayerViewController first. This prevents the issue from happening then.

Any tricky fix (siwzzling, dynamic subclassing, whatever) is too risky, and we haven't the time to find how this could be made.

pyby commented 3 years ago

This is really a tricky workaround. The memory graph showed an internal AVPlayerController and more, getting the AVPlayer alive.

With the workaround applied, the same peace of code releases the AVPlayer itself, like on previous iOS versions.

Screenshot 2020-09-19 at 00 38 07
defagos commented 3 years ago

Since the trick involves view controller presentation, I checked there is no negative impact on view appearance (e.g. duplicate -viewWillAppear: calls which might trigger some app logic twice). Everything works as expected and the fact there is a secret presentation involved cannot be seen.