Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: prevent album art rendering when modal is open #246

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

soifou
Copy link
Contributor

@soifou soifou commented Feb 7, 2025

Problem:

  • Album art rerendering could overlap open modals, making content unreadable
  • This occurred with events like UiEvent::SongChanged, UiEvent::Reconnected,
    and AppEvent::Resized while a modal was open on the queue list

Solution:

  • Add an is_modal_open flag to AppContext to track modal state
  • Implement checks to prevent album art rendering when a modal is open
  • Defer album art updates until modal is closed

@soifou
Copy link
Contributor Author

soifou commented Feb 7, 2025

I've not found an easy way to know whether a modal is open hence the new flag in the context. I've tried to keep it simple while refactoring the match arms a bit (those context.render() calls were unnecessary, right?).

There's room for optimization here. Now, rmpc attempts to fetch the album art every time the modal closes, as the song might have changed in the meantime (potentially bringing up a new album). Instead of immediately rendering the previous album art, we could consider implementing a more efficient approach.

Do you see any other areas where we could optimize the album art handling?
Thought?

@soifou soifou force-pushed the fix/album-overlap-modal branch 2 times, most recently from d106798 to 761d412 Compare February 7, 2025 19:27
@mierak
Copy link
Owner

mierak commented Feb 7, 2025

Its always something with the album arts...

I've not found an easy way to know whether a modal is open hence the new flag in the context. I've tried to keep it simple while refactoring the match arms a bit (those context.render() calls were unnecessary, right?).

Cant we simply track it inside the album pane struct instead of context? The rest of the application does not care about modal being opened I think and we can always move it back to the context if needed.

Otherwise it looks fine to me, thanks!

Now, rmpc attempts to fetch the album art every time the modal closes, as the song might have changed in the meantime (potentially bringing up a new album). Instead of immediately rendering the previous album art, we could consider implementing a more efficient approach.

One thing that comes to mind is keeping track of whether the song changed while the modal was opened. If it did not we can render the old image, otherwise fetch the new one.

edit:

those context.render() calls were unnecessary, right?

Theres a bunch of those, yeah. They are a no-op when render was already requested for that frame so I am pretty liberal with them.

@soifou soifou force-pushed the fix/album-overlap-modal branch from 761d412 to 07b1a9a Compare February 7, 2025 19:55
Problem:
- Album art rerendering could overlap open modals, making content unreadable
- This occurred with events like `UiEvent::SongChanged`, `UiEvent::Reconnected`,
  and `AppEvent::Resized` while a modal was open on the queue list

Solution:
- Add an `is_modal_open` flag to AppContext to track modal state
- Implement checks to prevent album art rendering when a modal is open
- Defer album art updates until modal is closed
@soifou soifou force-pushed the fix/album-overlap-modal branch from 07b1a9a to 8e7a27d Compare February 7, 2025 20:12
@soifou
Copy link
Contributor Author

soifou commented Feb 7, 2025

Cant we simply track it inside the album pane struct instead of context?

Absolutely, done.

One thing that comes to mind is keeping track of whether the song changed while the modal was opened. If it did not we can render the old image, otherwise fetch the new one.

I thought about this too but did not want to overcomplicated the logic at first, done now.

I am pretty liberal with them.

Ok fine to know :) I thought it was an oversight

@soifou soifou marked this pull request as ready for review February 7, 2025 20:15
@mierak mierak merged commit b56d79e into mierak:master Feb 7, 2025
7 checks passed
@mierak
Copy link
Owner

mierak commented Feb 7, 2025

merged, thanks!

@soifou soifou deleted the fix/album-overlap-modal branch February 7, 2025 20:21
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants