GeopJr / Tuba

Browse the Fediverse
https://tuba.geopjr.dev/
GNU General Public License v3.0
557 stars 60 forks source link

[Bug]: Images going fullscreen and back animate to stretched fullscreen rather than to target best fit size #1122

Closed YaLTeR closed 1 day ago

YaLTeR commented 1 week ago

Describe the bug

When clicking on an image, it crossfades into a fullscreen media viewer, but the image itself crossfades into a fullscreen stretch. Instead, it should crossfade into its target best fit location.

Steps To Reproduce

  1. Click on some image whose aspect ratio significantly mismatches the Tuba window aspect ratio.

Logs and/or Screenshots

https://github.com/user-attachments/assets/2eb7a714-f174-4f38-b7ba-e7155011eee5

You can see the problem clearly on freeze frames like:

mpv-shot0001

Instance Backend

Mastodon

Operating System

Fedora 40 Silverblue

Package

Flatpak

Troubleshooting information

os: GNOME 46 (Flatpak runtime) prefix: /app flatpak: true version: 0.8.4 (production) gtk: 4.14.5 (4.14.4) libadwaita: 1.5.4 (1.5.3) libsoup: 3.4.4 (3.4.4) libgtksourceview: 5.12.1 (5.12.1)

Additional Context

No response

GeopJr commented 1 week ago

My initial thought is that it's not worth it (unless I'm misunderstanding what the desired outcome is).

As it stands, the ScaleRevealer (the 'animation'), works by snapshotting the source widget and the target widget and crossfading between them.

The main issue is that there are way too many moving parts to have an 'expand to target size' animation work reliably and seamlessly.

From Tuba's side, there are options to letterbox attachment thumbnails and not enlarge media in the media viewer. That means that when viewed in the media viewer, images can actually be smaller than that the thumbnail.

From fedi backends' side, thumbnail sizes might differ from the full-size attachment, video thumbnails are often square and do not match the first frame of the video. Audio files usually don't have thumbnails and the media viewer will display an audio visualizer anyway.

I can play around with it and see if maybe snapshotting the child widgets or maybe changing when the crossfade starts will have a nicer effect, but I'd rather avoid doing more complex snapshot manipulation

YaLTeR commented 1 week ago

Hm, I understand that there are difficulties here, but maybe preserving the thumbnail aspect ratio during the crossfade would already make it better?

GeopJr commented 1 week ago

Can you do me a favor and try the letterbox setting? To me that looks like the desired effect, if you can confirm, I can start working with that in mind:

https://github.com/user-attachments/assets/5fa44b7f-2fd3-48f5-ba47-f2bc77e8daf1

(animation is slowed down by 1s to showcase it)

YaLTeR commented 1 week ago

It seems better on your video; for me with letterboxing it still tries to stretch the image to the full screen:

Screenshot from 2024-09-22 16-11-50

Screenshot from 2024-09-22 16-12-00

GeopJr commented 1 week ago

Thanks! Rethinking it a bit, we can basically just skip snapshoting the source widget (or start the cross fade much earlier so we avoid the first few ms showing the media viewer)

1.3s

https://github.com/user-attachments/assets/0475d28f-ea46-4249-9114-8448cc7e7355

.3s (default speed) (the media viewer being shown at the attachment position is more prominent when it's fast, we can just start the fading earlier to overcome that I guess)

https://github.com/user-attachments/assets/352f91b5-c61e-4fc4-ae42-40285f43f39e

(the first two attachments in the videos have the same aspect ratio as the ones in yours)