Skip to content

Always go to next source in player and add thread safety#2733

Merged
fire-light42 merged 4 commits intorecloudstream:masterfrom
Luna712:player-gotonext
May 4, 2026
Merged

Always go to next source in player and add thread safety#2733
fire-light42 merged 4 commits intorecloudstream:masterfrom
Luna712:player-gotonext

Conversation

@Luna712
Copy link
Copy Markdown
Contributor

@Luna712 Luna712 commented Apr 29, 2026

We don't want to ever kick out of the player if the first source fails, we can just show the unknown error toast and still go to the next source for more stable error handling. In the future we can still expand the different types of toasts shown to be clear about what the error is, but in reality we should never just kick out of the player if the first source is an error and there are other sources.

This also adds thread safety, and fixes issues with context required on the UI thread. Before lint couldn't follow ioSafe or other custom Coroutines methods, but this adds annotations to tell lint to follow properly ensuring proper build failures with WrongThread should it be called on the wrong thread.

For example with context:

Error: Method getContext must be called from the UI thread, currently inferred thread is worker thread

Is now given if called on the wrong thread. Doing it like this also would have caught other issues in the past as well.

Also, androidx.annotation:annotation is fully KMP compatible so has no issues with being in commonMain in library either. Just for consistency to ensure we always use the same version, it is also added explicitly to the app module.

We don't want to ever kick out of the player if the first source fails, we can just show the unknown error toast and still go to the next source for more stable error handling. In the future we can still expand the different types of toasts shown to be clear about what the error is, but in reality we should never just kick out of the player if the first source is an error and there are other sources.
Comment thread app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerView.kt Outdated
Copy link
Copy Markdown
Collaborator

@fire-light42 fire-light42 left a comment

Choose a reason for hiding this comment

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

The idea of this is to handle irrevocable and unknown errors by simply exiting the player, and can be seen as a soft app crash. If we do not know what happen, the system may have been left in a bad state causing worse problems than if we did not exit.

This is the general java philosophy, but I can see why it may cause user friction. Especially given that no such problem is realistically expected to happen.

Comment thread app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerView.kt Outdated
@Luna712 Luna712 changed the title Always go to next source in player regardless of what error is received Always go to next source in player and add thread safety Apr 30, 2026
@Luna712 Luna712 requested a review from fire-light42 April 30, 2026 19:34
Comment thread app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt Outdated
@Luna712 Luna712 requested a review from fire-light42 May 1, 2026 22:58
@fire-light42 fire-light42 merged commit 948a2c1 into recloudstream:master May 4, 2026
1 of 2 checks passed
@Luna712 Luna712 deleted the player-gotonext branch May 4, 2026 20:08
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