LeoKlaus / plappa

An Audiobook client for Jellyfin and AudioBookShelf, written in Swift/SwiftUI.
https://plappa.me
160 stars 0 forks source link

[BUG] Swiping down to dismiss the currently playing media is laggy. #69

Closed RobbyMeeker closed 2 months ago

RobbyMeeker commented 2 months ago

Describe the bug This is admittedly kind of a nit-pick, but swiping down on the current playback is much slower and laggier than other apps. Here's a comparison video: the first half is from Plappa, and the last is from Pocket Casts.

https://github.com/LeoKlaus/plappa/assets/49583515/a54f966f-3116-41d3-a5e2-f0a4f2dd4e5a

I have a feeling its related to the blurred background of the artwork, it happens with all of my media regardless of image resolution. Maybe it would be nice to have an option to disable this blurring if that is indeed the cause.

To Reproduce Steps to reproduce the behavior:

  1. Open app.
  2. Play any media.
  3. Notice laggy animation when swiping down to dismiss current playback info.

Expected behavior Smooth animation when dismissing media info.

Environment(please complete the following information):

LeoKlaus commented 2 months ago

Hey RobbyMeeker, thanks for reaching out!

I have a feeling its related to the blurred background of the artwork, it happens with all of my media regardless of image resolution. Maybe it would be nice to have an option to disable this blurring if that is indeed the cause.

It's actually caused by the .offset(x:y:) modifier I used to make the overlay draggable at all. SwiftUI doesn't offer a draggable fullscreen cover (despite many default iOS apps using them), so I had to create my own version. For some reason, the modifier causes the view to redraw with every frame (even if the view is conforming to Equatable).

I'm still looking for a satisfying solution, but haven't really found a well working native implementation.

RobbyMeeker commented 2 months ago

Interesting, pretty bizarre that there is no native solution to such a widespread feature. Hopefully there's a good solution out there.

LeoKlaus commented 2 months ago

I think I got it.

The new solution is in build 3 or newer of TestFlight version 1.1.4 if you want to check it out.

The new implementation is much more performant, but does seem to intermittently ignore the devices safe zones (the small pill shape at the top moves up into the notch/dynamic island and the corner radius of the view is sometimes ignored).

RobbyMeeker commented 2 months ago

So much better! Smooth as butter! Thanks.

While I'm nitpicking though, it seems like the distance to dismiss is quite high compared to other apps. It makes it a little harder to flick down with a small swipe like you can with other implementations. Here's a video example with comparisons.

https://github.com/LeoKlaus/plappa/assets/49583515/c082c10d-914c-4dfa-bbad-e4e19ce2dc34

LeoKlaus commented 2 months ago

I've just released 1.1.4 build 7 to TestFlight, it adds a check for the drag velocity. "Flicking down" the player should now work as expected :)

RobbyMeeker commented 2 months ago

Works great now, thanks!