Swiftfin icon indicating copy to clipboard operation
Swiftfin copied to clipboard

[iOS] Rotation doesn't work in new media player

Open samglt opened this issue 3 months ago • 10 comments

As noted in #1581, there are some issues when rotating the new player view. Transcoded video doesn't properly fill the screen and locks up until you force quit the app, and on my device non-transcoded video also doesn't fill the screen, but you can still rotate back to portrait without quitting the app.

This happens on iOS 18 & 26 on my devices

Example

https://github.com/user-attachments/assets/9303c7e1-bb4a-4fa1-a6f7-2e77833e23d0

samglt avatar Sep 20 '25 01:09 samglt

Looking into it more, I think the screen filling issue is related to the NavigationRoute's .fullscreen transition style, since I can replace the VideoPlayerViewShim here with a Rectangle and the screen still doesn't fill on rotation. I can also use change .fullscreen to .push and the player rotates fine.

samglt avatar Sep 20 '25 19:09 samglt

I was looking at this for #1713 and I was noticing that the fullscreen for iOS is a lot busier compared to tvOS. This could be related to what's going on here:

NavigationInjectionView.swift:

.presentation(
    $coordinator.presentedFullScreen,
    transition: .zoomIfAvailable(
        options: .init(
            dimmingVisualEffect: .systemThickMaterialDark,
            options: .init(
                isInteractive: isPresentationInteractive
            )
        ),
        otherwise: .slide(.init(edge: .bottom), options: .init(isInteractive: isPresentationInteractive))
    )
) { routeBinding, _ in
    let vc = UIPreferencesHostingController {
        NavigationInjectionView(coordinator: .init()) {
            routeBinding.wrappedValue.destination
                .environment(\.presentationControllerShouldDismiss, $isPresentationInteractive)
        }
    }

    // TODO: presentation options for customizing background color, dimming effect, etc.
    vc.view.backgroundColor = .black

    return vc
}

JPKribs avatar Sep 20 '25 19:09 JPKribs

That's part of the new player change, it was simpler previously. I haven't checked what happens if you replace it with the previous commit

samglt avatar Sep 20 '25 19:09 samglt

On iOS/iPadOS Transmission.PresentationLink is used to get more complex behavior. In the app delegate, the top-most UIPreferencesHostingController is then used to determine the orientation mask.

However, I'm now wondering if my comment:

ultimately different than https://github.com/jellyfin/Swiftfin/issues/1149.

is incorrect, as this is mostly seen with transcoded streams with VLCKit. Meaning, I'm wondering if there's a threading issue that's causing the UIPreferencesHostingController to not properly respond and become unresponsive.

LePips avatar Sep 21 '25 01:09 LePips

I have a partial fix for this, updating the frame size in UIPreferencesHostingController. This doesn't affect the transcoded video side of this; the UI still stops responding and the video player doesn't resize either, even though it fixes the issue in non-transcoded video like in my above example.

override public func viewWillTransition(
    to size: CGSize,
    with coordinator: any UIViewControllerTransitionCoordinator
) {
    super.viewWillTransition(to: size, with: coordinator)
    view.frame.size = size
}

It doesn't look pretty, but making it look good is beyond my UIKit knowledge.

https://github.com/user-attachments/assets/4957fd01-737e-460d-9a25-459a2140c2e9

samglt avatar Sep 21 '25 05:09 samglt

A few more notes about the transcoded video issue:

  • I can avoid it when playing a video by immediately rotating my device while it's buffering, while waiting til it's playing causes the issue, which seems to be the opposite of what Joe experienced.
  • When I cause the issue in a fast release build, it looks exactly the same as before, but if I cause it in a slow debug build it also causes the video itself (not the controls) to stretch vertically and stay that way. That does sound like some kind of threading issue.

samglt avatar Sep 21 '25 05:09 samglt

Hm, now I'm facing this on every stream - which certainly didn't happen during development.

LePips avatar Sep 21 '25 23:09 LePips

Hm, now I'm facing this on every stream - which certainly didn't happen during development.

For the time being, to get the TestFlight out, does it make sense to keep this locked in landscape like previous? Then shoot to resolve this for the final 1.4 (worst case 1.5).

JPKribs avatar Sep 21 '25 23:09 JPKribs

Marking as External as this seems to be related to the Transmission package.

JPKribs avatar Sep 22 '25 01:09 JPKribs

After #1719 I still get this sometimes, with the following rough steps:

  1. I'm playing something
  2. Exited the app for a couple minutes with the audio paused
  3. Re-opened swiftfin to find the overlay responds but the video doesn't play
  4. Exited the player
  5. The interface outside the player isn't responding to input

samglt avatar Sep 28 '25 02:09 samglt

yes need to auto landscape on play, now is locked potrait unless phone rotate is on, prev build is fine. using streamfin/infuse now

nomnomdigital avatar Dec 16 '25 08:12 nomnomdigital