forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix Android startup crash: Linux libbass.so packaged in place of Android arm64 binary #224
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a7ac628
Fix ranked play chat deselecting when typing shift-numbers (#37450)
smoogipoo 9a28465
Implement WebSocket server skeleton for external integrations (#37335)
bdach 1eee6dc
Attempt to improve safety of pushing matchmaking screens (#37452)
bdach 553c203
Do not cache null values in beatmap lookup cache (#37456)
bdach 71356a9
Use placeholder user models in ranked play if online lookups fail (#3…
bdach 71b3d51
Rewrite ranked play card song preview playback logic to hopefully wor…
bdach 7b0e5ec
Code quality improvements for child/draw order handling in `HandOfCar…
minetoblend 00e1879
Merge ppy/osu master (7 commits): ranked play/matchmaking + WebSocket…
invalid-email-address 3db4639
Fix bass DllNotFoundException + harden APK verification + merge upstr…
invalid-email-address d16ad3d
Fix CI: brace block around Key.Space switch case after upstream merge…
Copilot bc9b8ae
README: drop crash framing for stability section
Copilot 3031578
Address Copilot AI review: SongPreview playback, WebSocket UTF-8/boun…
Copilot bc1f72b
Fix CS0246: add missing `using osu.Desktop.IPC;` for OsuWebSocketProv…
Copilot 3dd376b
Address CodeQL: use `System.Threading.Lock` instead of `object` for W…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
| // See the LICENCE file in the repository root for full licence text. | ||
|
|
||
| using Newtonsoft.Json; | ||
|
|
||
| namespace osu.Desktop.IPC.Messages | ||
| { | ||
| public class HitCountMessage : OsuWebSocketMessage | ||
| { | ||
| [JsonProperty("new_hits")] | ||
| public long NewHits { get; init; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
| // See the LICENCE file in the repository root for full licence text. | ||
|
|
||
| using Newtonsoft.Json; | ||
| using osu.Framework.Extensions.TypeExtensions; | ||
|
|
||
| namespace osu.Desktop.IPC.Messages | ||
| { | ||
| public abstract class OsuWebSocketMessage | ||
| { | ||
| [JsonProperty("type")] | ||
| public string Type { get; } | ||
|
|
||
| protected OsuWebSocketMessage() | ||
| { | ||
| Type = GetType().ReadableName(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
| // See the LICENCE file in the repository root for full licence text. | ||
|
|
||
| using System; | ||
| using System.Linq; | ||
| using System.Threading; | ||
| using osu.Desktop.IPC.Messages; | ||
| using osu.Framework.Allocation; | ||
| using osu.Framework.Bindables; | ||
| using osu.Framework.Extensions; | ||
| using osu.Framework.Graphics; | ||
| using osu.Framework.Logging; | ||
| using osu.Game.Configuration; | ||
| using osu.Game.IPC; | ||
| using osu.Game.Online.Multiplayer; | ||
| using osu.Game.Rulesets.Scoring; | ||
| using osu.Game.Scoring; | ||
| using JsonConvert = Newtonsoft.Json.JsonConvert; | ||
|
|
||
| namespace osu.Desktop.IPC | ||
| { | ||
| public partial class OsuWebSocketProvider : Component | ||
| { | ||
| private WebSocketServer? server; | ||
| private readonly Bindable<ScoreInfo> lastLocalScore = new Bindable<ScoreInfo>(); | ||
|
|
||
| [BackgroundDependencyLoader] | ||
| private void load(SessionStatics sessionStatics) | ||
| { | ||
| server = new WebSocketServer(49727); | ||
| server.StartAsync().FireAndForget(onError: ex => Logger.Error(ex, "Failed to start websocket")); | ||
|
|
||
| sessionStatics.BindWith(Static.LastLocalUserScore, lastLocalScore); | ||
| } | ||
|
|
||
| protected override void LoadComplete() | ||
| { | ||
| base.LoadComplete(); | ||
|
|
||
| lastLocalScore.BindValueChanged(val => | ||
| { | ||
| if (val.NewValue == null) | ||
| return; | ||
|
|
||
| if (server?.IsRunning != true) | ||
| return; | ||
|
|
||
| var msg = new HitCountMessage { NewHits = val.NewValue.Statistics.Where(kv => kv.Key.IsBasic() && kv.Key.IsHit()).Sum(kv => kv.Value) }; | ||
| broadcast(msg); | ||
| }); | ||
| } | ||
|
|
||
| private void broadcast(OsuWebSocketMessage message) | ||
| { | ||
| if (server?.IsRunning != true) | ||
| return; | ||
|
|
||
| string messageString = JsonConvert.SerializeObject(message); | ||
| server.BroadcastAsync(messageString).FireAndForget(); | ||
| } | ||
|
|
||
| protected override void Dispose(bool isDisposing) | ||
| { | ||
| base.Dispose(isDisposing); | ||
|
|
||
| if (server?.IsRunning == true) | ||
| { | ||
| var cts = new CancellationTokenSource(); | ||
| cts.CancelAfter(TimeSpan.FromSeconds(10)); | ||
| server.StopAsync(cts.Token).WaitSafely(); | ||
| server = null; | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
| // See the LICENCE file in the repository root for full licence text. | ||
|
|
||
| using System; | ||
| using System.Net.WebSockets; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using osu.Game.IPC; | ||
|
|
||
| namespace osu.Game.Tests.IPC | ||
| { | ||
| public sealed class WebSocketClient : IDisposable | ||
| { | ||
| public event Action<string>? MessageReceived; | ||
| public event Action? Closed; | ||
|
|
||
| private readonly int port; | ||
| private WebSocketChannel? channel; | ||
|
|
||
| public WebSocketClient(int port) | ||
| { | ||
| this.port = port; | ||
| } | ||
|
|
||
| public async Task Start(CancellationToken cancellationToken = default) | ||
| { | ||
| var webSocket = new ClientWebSocket(); | ||
| await webSocket.ConnectAsync(new Uri($@"ws://localhost:{port}/"), cancellationToken); | ||
| channel = new WebSocketChannel(webSocket); | ||
| channel.MessageReceived += msg => MessageReceived?.Invoke(msg); | ||
| channel.ClosedPrematurely += () => Closed?.Invoke(); | ||
| channel.Start(cancellationToken); | ||
| } | ||
|
|
||
| public async Task SendAsync(string message) | ||
| { | ||
| if (channel == null) | ||
| throw new InvalidOperationException($@"Must {nameof(Start)} first."); | ||
|
|
||
| await channel.SendAsync(message); | ||
| } | ||
|
|
||
| public async Task StopAsync(CancellationToken stoppingToken = default) | ||
| { | ||
| try | ||
| { | ||
| if (channel != null) | ||
| await channel.StopAsync(stoppingToken).ConfigureAwait(false); | ||
| } | ||
| catch (OperationCanceledException) | ||
| { | ||
| // has to be caught manually because outer task isn't accepting `stoppingToken`. | ||
| } | ||
| } | ||
|
|
||
| public void Dispose() | ||
| { | ||
| channel?.Dispose(); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dispose()creates aCancellationTokenSourcebut never disposes it, and also never callsDispose()on theWebSocketServerafter stopping it. This can leak unmanaged handles (listener, wait handles) across screen transitions/shutdown. Use ausing/try-finallyfor the CTS and ensure the server is disposed after stopping (even if stop fails/times out).