Focus update crashes UI on tvOS 15.0

I'm encountering UI update issues whenever I'm selecting an option for new quality from the menu in new tvOS 15.0 controls.

FYI: selecting a quality makes a new content node and replaces previous node in player.

However the behaviour is different for two cases

  1. whenever I select an option while content is PLAYING - focus update is okay and and i get the expected outcome.
  2. whenever I select an option while content is ON PAUSE - focus update crashes ui and it moves to previously opened screen while im hearing player playing somewhere in the back

WHEN PLAYING

The focus debug just before focus update shows:

  • AVPlayerViewController.view.preferredFocusEnvironments:

a. _AVPlayerViewControllerContainerView (skipping collectionView)

<_AVPlayerViewControllerContainerView: 0x7fa0d27f5b30; frame = (0 0; 1920 1080); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600000f7de90>; layer = <CALayer: 0x6000000df8a0>> (view controller is <AVPlayerViewController: 0x7fa0d31f4a00>

b. container's preferred focusEnvironments:

<_AVFocusContainerView: 0x7fa0c68a4c30; frame = (0 0; 1920 1080); gestureRecognizers = <NSArray: 0x600000f68e40>; layer = <CALayer: 0x6000000d79a0>> (view controller is <AVPlayerViewController: 0x7fa0d31f4a00>)

WHEN IN PAUSE

The focus debug just before focus update in this case shows: a. CollectionView - the customMenuItems collectionView

<UICollectionView: 0x7fa0d3143800; frame = (0 844; 1920 64); autoresize = W+H; gestureRecognizers = <NSArray: 0x600000f43300>; layer = <CALayer: 0x6000000dccc0>; contentOffset: {0, 0}; contentSize: {1760, 64}; adjustedContentInset: {0, 0, 0, 0}; layout: <AVxCollectionViewLayout: 0x7fa0d2760580>; dataSource: <AVxCollectionViewController: 0x7fa0c6873e00>>

b. CollectionView.preferredFocusEnvironments is cell - is one of customMenuItems

<AVxOverlayToolCell: 0x7fa0dd721140; baseClass = UICollectionViewCell; frame = (1606 0; 64 64); layer = <CALayer: 0x60000012b980>>

c. Cell's preferredFocusEnvironments is empty.

I don't know if its native bug or there's a way to solve this myself.

Replies

What's the crashing thread's backtrace?

  • @deirdresm

    Player UI is crashing, the app doesn't.

    Update: I've tried debugging what exactly breaks the UI and why it doesn't crash when playing and figured out that code self.playerViewController?.playbackControlsIncludeTransportBar = false is the issue. But its not breaking it, its fixes it for playing state.

    For example. Im on a breakpoint in a stopped state (before loading state and before changing content nodes) If I were in a playing state before and i set playbackControlsIncludeTransportBar = false - ui doesn't break If I were in a paused state before and I set it to false - ui breaks

    but removing that code self.playerViewController?.playbackControlsIncludeTransportBar = false in a didSet for stopped state makes ui break for playing state too.

    I'm really confused.

    BUT!

    I tried changing to self.playerViewController?.showsPlaybackControls = false instead and this way UI doesn't break but apple recommends not to use this property to change visibility cause it will break the ui (it doesn't in my case but I still don't want to use that)

  • seems like focus is not the problem but still no clue what to do

Add a Comment