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

Uploaded Artists: fix fetching and displaying uploaded artists #107

Merged
merged 10 commits into from
Dec 10, 2024

Conversation

mattcarter11
Copy link
Contributor

@mattcarter11 mattcarter11 commented Nov 19, 2024

Before, you could not fetch and display the privately owned (uploaded) artists

Uploaded artist

YouTube artist

Also fixed:

  • not all chips syncing when being selected
  • don't sync if no connection. Finish sync if no error while fetching ytm data
  • when syncing playlist, exclude liked playlist by id, not by order
  • change text sort by date to sort by liked when songs liked filter is active

@mattcarter11
Copy link
Contributor Author

@mikooomich a fix from a missing piece from the big PR

@mattcarter11 mattcarter11 force-pushed the singelton-sync-and-chip-loader branch from 0ebd7a2 to 267b158 Compare December 3, 2024 22:53
@mikooomich
Copy link
Collaborator

Do you know why it crashes when trying open pages for local artists?


Process: com.dd3boh.outertune.debug, PID: 26517
java.lang.NullPointerException: Parameter specified as non-null is null: method androidx.room.RoomSQLiteQuery.bindString, parameter value
	at androidx.room.RoomSQLiteQuery.bindString(Unknown Source:3)
	at com.dd3boh.outertune.db.DatabaseDao_Impl.__fetchRelationshipartistAscomDd3bohOutertuneDbEntitiesArtistEntity_1(DatabaseDao_Impl.java:12524)
	at com.dd3boh.outertune.db.DatabaseDao_Impl.-$$Nest$m__fetchRelationshipartistAscomDd3bohOutertuneDbEntitiesArtistEntity_1(Unknown Source:0)
	at com.dd3boh.outertune.db.DatabaseDao_Impl$112.call(DatabaseDao_Impl.java:9829)
	at com.dd3boh.outertune.db.DatabaseDao_Impl$112.call(DatabaseDao_Impl.java:9802)
	at androidx.room.CoroutinesRoom$Companion$createFlow$1$1$1.invokeSuspend(CoroutinesRoom.kt:129)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: 

For example, local artists look like this where the are some null fields, and isLocal = 1
image

The page before this pr
image

@mattcarter11 mattcarter11 force-pushed the singelton-sync-and-chip-loader branch from ef1a0fe to a95972e Compare December 7, 2024 18:41
@mattcarter11 mattcarter11 force-pushed the singelton-sync-and-chip-loader branch from a95972e to da1032c Compare December 7, 2024 18:43
@mattcarter11
Copy link
Contributor Author

@mikooomich i'll take a look.

Also here I've added two sync fixes:

  • not all chips syncing when being selected
  • don't sync if no connection. Finish sync if no error while fetching ytm data

@mattcarter11 mattcarter11 force-pushed the singelton-sync-and-chip-loader branch from da1032c to fe215a3 Compare December 7, 2024 20:29
@mattcarter11
Copy link
Contributor Author

@mikooomich I think I've found the problem and fixed it!

@mattcarter11
Copy link
Contributor Author

mattcarter11 commented Dec 7, 2024

@mikooomich also, after adding the corutines to sync songs faster. I found a kind of problem caused by that: the songs are added in a different order compared to what YTM returns. So, if you sort by date added, it's not identical to what YTM responds.

This I think is fine except for likes, I find it annoying that if I order songs by liked date, it's not identical to YTM. What do you think? Should we revert the corutine at the end of syncLikedSongs() and just leave a for each for adding the likes?
image

Another option I see is to do first the toggle like logic linearly and then insert/update with a corutine

@mikooomich
Copy link
Collaborator

@mattcarter11

Another option I see is to do first the toggle like logic linearly and then insert/update with a corutine

IIRC toggle like just assigns a timestamp, so that would be a best of both worlds solution. Though, I'd have some thread limit (ex. thread pools) for jobs like this, if dispatchers doesn't do this automatically.

But also...

Does coroutines can provides significant performance boost over just a simple for? The db transactions are processed sequentially anyways. I'd imagine you put the val localSong = outside of the transaction because it deadlock(?). Maybe putting everything in one transaction and doing everything in a regular for loop may yield better results, and avoid such deadlocks?

I haven't had the time to look at this too closely, but in general, do what you think would be best; you probably are more familiar with this code than me. Thanks for doing the sync work I dread lol

@mattcarter11 mattcarter11 force-pushed the singelton-sync-and-chip-loader branch from 350375a to eed6164 Compare December 8, 2024 21:21
@mattcarter11
Copy link
Contributor Author

@mikooomich okey. For now, I'll let the likes sync as a simple for loop. Later we can improve this. If the rest of the changes seem ok could you merge the PR? I have other changes on a branch based on this one but related to other stuff that i would like to open a PR.

Just for spoliers.....🤫🤫

@mikooomich mikooomich force-pushed the singelton-sync-and-chip-loader branch from 4060eb3 to 5333c96 Compare December 10, 2024 01:40
@mikooomich
Copy link
Collaborator

Yeah, I'll merge it and later on make stuff efficient and/or fix bugs.

Remote artists have a little ui issue when offline. Maybe squeeze this fix in somewhere, or I'll get around to it... eventually
image

@mikooomich mikooomich merged commit 3ef82cc into DD3Boh:dev Dec 10, 2024
1 check passed
@mattcarter11 mattcarter11 deleted the singelton-sync-and-chip-loader branch December 10, 2024 16:35
if (!showLocal) {
showLocal = true
}
}
Copy link
Collaborator

@mikooomich mikooomich Dec 10, 2024

Choose a reason for hiding this comment

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

@mattcarter11 do you know why this is done? Doesn't this always set showLocal to true? Currently, when online, only local content will be shown, and to my knowledge, the online content is never shown.

From what I gather, you want to show offline content when offline and online content when online?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, I would like to merge in the compose 1.7 changes soon (since they'll probably end up conflicting badly), are you ok with me merging that in after your 3 prs (#127 #125 #121)?

Here is the branch with compose changes rebased on current dev https://github.com/mikooomich/OuterTune/tree/canary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mikooomich ow, it's missing some logic, here's a fix: #128
About the merge, yes, currently I don't have new code to PR (but I will) so all good for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants