Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix inconsistency between user interaction and database commit order when re-adding videos to the playlist #8248

Merged
merged 2 commits into from
Oct 3, 2023

Conversation

dtcxzyw
Copy link
Contributor

@dtcxzyw dtcxzyw commented Apr 17, 2022

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

The reason for this issue is an inconsistency between user interaction and database commit order.

Expected behavior

delete - commit (delete) - add - commit (add)

Actual behavior

delete - add - commit (add, commit immediately) - commit (delete, commit after ~10s due to the debouncedSaveSignal)

Best Solution

Removes all debounced commit strategies. Sequential consistency is guaranteed by database transactions.

But I don't know why the delete operation uses the deferred commit strategy. BTW, I realize PR #8221 could have many conflicts with this solution. So I took a conservative approach to fix it.

Current Solution

Concurrent operations on the playlist database occur if and only if the user opens both LocalPlaylistFragment and VideoDetailFragment as described in the related issue. So I force all delete operations to be committed to the database before adding.

Before/After Screenshots/Screen Record

  • Before:
before_small-mute.mp4
  • After:
after_small-mute.mp4

From main page tab:

after2_mute.mp4

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.

Due diligence

@sonarcloud
Copy link

sonarcloud bot commented Apr 19, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Comment on lines 454 to 456
if (fragment instanceof LocalPlaylistFragment) {
((LocalPlaylistFragment) fragment).commitChanges();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the cases when the local playlist fragment is a main page tab?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case can also be handled by these lines.
I tested this case on my device. It works fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmh, I don't understand why those lines would handle it. If the fragment is a main page tab, then it is not the parent of the VideoDetailFragment anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a supplementary video for this case. Did I understand you correctly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NewPipe allows customizing main page tabs, and even insert local playlists there. See "Settings -> Content -> Content of main page -> + -> Playlist page". That option adds a playlist in the main page (not a "Bookmarked playlists" tab, but really a "Playlist" tab!).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2de8282

@triallax triallax added database Issue is related to database operations bug Issue is related to a bug labels Jul 26, 2022
@opusforlife2 opusforlife2 added the playlist Anything to do with playlists in the app label Oct 24, 2022
@TobiGr
Copy link
Member

TobiGr commented Aug 17, 2023

  • Rebased
  • Fixed the behaviour when LocalPlaylistFragment is used as frontpage tab
Before After
MainTab_LocalPlaylist_Before.webm MainTab_LocalPlaylist_After.webm

Copy link
Member

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay and thank you for submitting the fix!

@sonarcloud
Copy link

sonarcloud bot commented Aug 17, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@TobiGr TobiGr requested a review from Stypox August 17, 2023 16:03
@TobiGr TobiGr force-pushed the fix-readd-to-playlist branch 3 times, most recently from 5fbbcf4 to b1a1e78 Compare September 27, 2023 08:08
@sonarcloud
Copy link

sonarcloud bot commented Oct 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Stypox Stypox merged commit bff7ada into TeamNewPipe:dev Oct 3, 2023
8 of 9 checks passed
This was referenced Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug database Issue is related to database operations playlist Anything to do with playlists in the app
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot readd video to playlist
5 participants