SRGSSR / pillarbox-apple

A next-generation reactive media playback ecosystem for Apple platforms.
https://testflight.apple.com/join/TS6ngLqf
MIT License
54 stars 8 forks source link

Media selection is not updated in menu when a change is applied programmatically #598

Closed defagos closed 12 months ago

defagos commented 12 months ago

Description of the problem

With #584, #595 and #596 we attempted to mitigate iOS 17 performance issues associated with media selection criteria retrieval, attempting to build a coherent API in the process.

This sadly fails, though, since the current approach does not handle non-interactive changes at the menu level. We attempted to solve a performance issue with an API update, but the new API is sadly not good enough. We need a different approach, preserving our prior API while mitigating the performance issues.

Relevant stack trace or log output

No response

Reproducibility

Always

Steps to reproduce

  1. Tweak our demo PlaybackView so that the forward button sets Japanese for subtitles.
  2. Run the demo.
  3. Pick French for subtitles.
  4. Tap on the forward button.
  5. Open the menu again. The language is incorrectly still French.

Library version

0.7.0

Operating system

iOS 17

Code sample

No response

Is there an existing issue for this?

defagos commented 12 months ago

The current API proposal fails as follows:

With the older API we had we used a binding which would retrieve the current selection not from an additional source of truth (a local state), but from the only reliable source of truth, namely the player.

For the same reason our current playback speed API, totally analogous, can be considered correct.

defagos commented 12 months ago

I implemented the caching strategy outlined in #595:

But I still think that not being able to use standard observability for menu implementation (and our mediaOption(for:) binding) is an API issue. I will therefore propose we cache media selection criteria at the player instead, thus mitigating the performance issues observed in https://github.com/SRGSSR/pillarbox-apple/issues/584. The criteria are changed very rarely by the user, so having them cached for the lifetime of the player is not a real issue in practice.

It comes at a small price but is likely our current best option until the performance issue is fixed, at which point the cache can simply be removed.