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] Resolve a crash while close multiple player windows simultaneously #225

Open
doggy opened this issue Jun 16, 2024 · 1 comment
Open

Comments

@doggy
Copy link
Contributor

doggy commented Jun 16, 2024

HttpServer

        }, disconnected: { [weak self] session in
            Log("Websocket client disconnected.")
            self?.connectedItems.removeAll { $0.session == session
            }
            guard let items = self?.connectedItems else { return }
            self?.danmakus.removeAll { dm in
                let remove = !items.contains(where: { $0.url == dm.url })
                if remove {
                    dm.stop()
                }
                return remove
            }

The line which contains self?.danmakus leads a high probability app crash if you open more than 2 IINA windows and close them all simultaneously by pressing keyboard Q.

@doggy
Copy link
Contributor Author

doggy commented Jun 16, 2024

The fix PR is attached here. Already tested and verified on my M1 Mac.

The main reason for the crash is the multiple threads will send the disconnect event at same time but the list is not provide thread safety logic. There is a high probability of this happening when using the keyboard Q to exit multiple IINA windows.

As you might consider the crash also occurs when adding new elements to danmakus. Yes, in rare cases this can happen, so it is good to add this protection to loadNewDanmaku()

Please review my changes. If you have any questions, please reply and let me know. I will check this PR frequently recently.

BTW, I must say this is a very convenient app for watching live broadcasts! Use it every day and night!
I am very grateful to the author for his continuous updates over the years!

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

No branches or pull requests

1 participant