Preserve web frontend playlist after Performous disconnects
What does this PR do?
This will attempt to restore the playlist on the web frontend after it disconnects with Performous (for example, when it crashes).
Motivation
When Performous crashes, the current playlist gets lost. This is an intended behavior, but can get cumbersome on the web frontend whenever Performous is used during events where the queue could get quite long. One solution is to make a screenshot before restarting Performous and manually re-add the songs, however, this isn't efficient, and can take up quite some time, even minutes before people can request songs again.
Additional Notes
Some modifications to the original code has been done. I've tried to keep the original code style as much as possible, including using double quotes instead of single quotes. An attempt has been made to keep it ES2015 compatible, however, there might be issues due to that. Eventually it does need to be rewritten to ESNext, but that will take some time.
Download the artifacts for this pull request:
- Performous-1.3.1+git-fd50f93-PR1050-alpha-fedora_39.rpm.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha-debian_13.deb.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha-fedora_42.rpm.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha-fedora_40.rpm.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha-fedora_41.rpm.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha-fedora_36.rpm.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha-ubuntu_24.04.deb.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha-fedora_37.rpm.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha-ubuntu_22.04.deb.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha-fedora_38.rpm.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha-ubuntu_20.04.deb.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha-debian_12.deb.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha.AppImage.zip
- Performous-1.3.1+git-fd50f93-PR1050-alpha-mingw-w64.exe.zip
- MacPorts-log-macos-14.tar.gz.zip
This service is provided by nightly.link. These artifacts will expire in 90 days and will not be available for download after that time.
Quality Gate passed
Issues
10 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.8% Duplication on New Code
Quality Gate passed
Issues
31 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.2% Duplication on New Code
I'll see if i can make some time later today to get this tested as i'd love to use it ~well hopefully i don't need to use it~ for the next event(s) :)
Tonight i'll do a final test with the huge library. I suspect no further issues and that it can be merged as is :) Thanks for the updates!
Testing:
Test 1
- Start Performous
- Add 3 tracks to playlist (but don't play any)
- Exit & Restart Performous
- Verified that playlist is found, and offered for re-loading. ✅
- Clicking [Restore Playlist] re-creates tracks, in previous order ✅
Test2
- Start Performous
- Add 3 tracks to playlist (but don't play any)
-
kill -9Performous & Restart Performous - Verified that playlist is found, and offered for re-loading. ✅
- Clicking [Restore Playlist] re-creates tracks, in previous order ✅
Test3
- ... as per Test1
- Observed that Playlist test matches previous selections ✅
Test4
- ... as per Test1
- Download Playlist JSON ✅
- Observed that Playlist JSON content matches previous selections ✅
Test5
- ... as per Test1
- Clicked [Remove playlist]
- Verified playlist cleared ✅
Test6
- ... After Test5 is run
- Restart Performous
- Verified playlist remains cleared ✅
Test7
- ... as per Test1
- Play through first song in playlist
- Refresh playlist during playback
- Observe first playlist track is played ✅
- Observe first playlist track is removed from playlist ✅
- Observe the on-screen track during the switch to Playlist Menu is auto-added to playlist ❌
- Observe the on-screen track during the switch to Playlist Menu is added twice to playlist ❌
Test8
- As per Test7
- Wait for playing song to finish, refreshing playlist occasionally
- Observe playlist correctness is maintained after track finishes playing ✅
I'll leave it there for the moment.
Failures in Test7 could be operator error - what should happen here?
Test7
- ... as per Test1
- Play through first song in playlist
- Refresh playlist during playback
- Observe first playlist track is played ✅
- Observe first playlist track is removed from playlist ✅
- Observe the on-screen track during the switch to Playlist Menu is auto-added to playlist ❌
- Observe the on-screen track during the switch to Playlist Menu is added twice to playlist ❌
This is the pre-existing behavior, currently playing songs are removed from the playlist. This is something I don't think should be changed, or even has to be. Most crashes happen near the end of the song or in-between songs, rarely in the middle of one, unless the song was corrupted or an unusual bug popped up, in the latter case you can manually queue the song again.
Test 9.
- Play playlist right through ✅
- Observe Performous plays fine. ✅
- Observe Web front-end pop-up a message "A previous playlist has been found", as if Performous has crashed ❌
- Observed the playlist contains that last track ??
As an ignorant user I did not expect this behaviour. I expected to see an empty list, or maybe something like "playlist has completed" message.
I'm wondering if we shouldn't push a JSON record like {"performous":"playlist-ended"} as a marker that the entire playlist has been consumed, rather than return an empty set from /api/getCurrentPlaylist.json.
Hmmm, now I've written that, it sounds dodgy.
The playlist reloader works well, but it cannot differentiate between a "used up" empty playlist, and "Performous crashed" empty playlist.
No, it truly is an oversight. I always look at the http response code to see if the application crashed or not.
Okay, I've been wracking my brains over this, but in search.js, there's a reference to the properties App and AppVersion, which causes the search not to work. It's easy for me to figure out what AppVersion is (it's most likely the version of the timing file, like, for USDX it would be 1.2.0 for the most recent, otherwise it's whatever was decided for the default version). But I'm not entirely sure about App. I want to fix it with this issue before I send it over for approval again, but I do need to be sure I'll fix it correctly. I assume App refers to the application the timing file was originally made for (StepMania, Frets On Fire, UltraStar Deluxe), but I'll have to be certain.
To be extra safe, I'll add the optional chaining operator to these variables, so that at the very least search will continue to work.
https://github.com/performous/performous/blob/d5278e3264e87b4a0d2815e1b67f0fd672e9305c/data/themes/default/www/js/search.js#L90