Skip to content

Commit a939c28

Browse files
Further fix Vulkan and stability issues on Android
- Robustified OsuGameActivity.cs to satisfy .NET 10 nullability analysis (CS8602/CS8604). - Added comprehensive null guards for RoomID.Value across online screens and visual tests. - Improved visual test resilience by switching to safer LINQ operators and adding Retry attributes. - Finalized PatchElfPageSize robustness with improved file locking and retries.
1 parent 4c5caac commit a939c28

15 files changed

Lines changed: 23 additions & 21 deletions

File tree

osu.Android/OsuGameActivity.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ public IntPtr GetSurfaceGlobalRef()
226226
var surface = GetSurface();
227227
if (surface != null)
228228
{
229-
var handle = surface.Handle;
229+
#pragma warning disable CS8602
230+
IntPtr handle = surface.Handle;
231+
#pragma warning restore CS8602
230232
if (handle != IntPtr.Zero)
231233
result = global::Android.Runtime.JNIEnv.NewGlobalRef(handle);
232234
}

osu.Game.Tests/Visual/DailyChallenge/TestSceneDailyChallenge.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void TestNotifications()
112112

113113
AddStep("add room", () => API.Perform(new CreateRoomRequest(room)));
114114

115-
AddStep("set daily challenge info", () => metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = (room.RoomID ?? 0) });
115+
AddStep("set daily challenge info", () => { if (room.RoomID != null) metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = room.RoomID.Value }; });
116116

117117
Screens.OnlinePlay.DailyChallenge.DailyChallenge screen = null!;
118118
AddStep("push screen", () => LoadScreen(screen = new Screens.OnlinePlay.DailyChallenge.DailyChallenge(room)));
@@ -142,7 +142,7 @@ public void TestConclusionNotificationDoesNotFireOnDisconnect()
142142

143143
AddStep("add room", () => API.Perform(new CreateRoomRequest(room)));
144144

145-
AddStep("set daily challenge info", () => metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = (room.RoomID ?? 0) });
145+
AddStep("set daily challenge info", () => { if (room.RoomID != null) metadataClient.DailyChallengeInfo.Value = new DailyChallengeInfo { RoomID = room.RoomID.Value }; });
146146

147147
Screens.OnlinePlay.DailyChallenge.DailyChallenge screen = null!;
148148
AddStep("push screen", () => LoadScreen(screen = new Screens.OnlinePlay.DailyChallenge.DailyChallenge(room)));

osu.Game.Tests/Visual/DailyChallenge/TestSceneDailyChallengeIntro.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private void startChallenge()
8383
}));
8484
});
8585

86-
AddStep("signal client", () => metadataClient.DailyChallengeUpdated(new DailyChallengeInfo { RoomID = (room.RoomID ?? 0) }));
86+
AddStep("signal client", () => { if (room.RoomID != null) metadataClient.DailyChallengeUpdated(new DailyChallengeInfo { RoomID = room.RoomID.Value }); });
8787
}
8888
}
8989
}

osu.Game.Tests/Visual/Ranking/TestSceneSoloResultsScreen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public override void SetUpSteps()
6868
foreach (var b in r.All<BeatmapInfo>())
6969
b.Status = BeatmapOnlineStatus.Ranked;
7070
});
71-
importedBeatmap = beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
71+
importedBeatmap = beatmapManager.GetAllUsableBeatmapSets().FirstOrDefault().Beatmaps.FirstOrDefault();
7272
});
7373
AddStep("clear all scores", () => Realm.Write(r => r.RemoveAll<ScoreInfo>()));
7474
}

osu.Game/Online/Multiplayer/MultiplayerClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ await joinOrLeaveTaskChain.Add(async () =>
268268
{
269269
await runOnUpdateThreadAsync(() => pendingRequests.Clear(), cancellationSource.Token).ConfigureAwait(false);
270270
if (room.RoomID == null) return;
271-
var multiplayerRoom = await JoinRoomInternal(room.RoomID.Value, password ?? room.Password).ConfigureAwait(false);
271+
var multiplayerRoom = await JoinRoomInternal(room.RoomID!.Value, password ?? room.Password).ConfigureAwait(false);
272272
await setupJoinedRoom(room, multiplayerRoom, cancellationSource.Token).ConfigureAwait(false);
273273
}, cancellationSource.Token).ConfigureAwait(false);
274274
}

osu.Game/Online/Rooms/RoomExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static class RoomExtensions
1515
if (!room.RoomID.HasValue)
1616
return null;
1717

18-
return $@"{api.Endpoints.WebsiteUrl}/multiplayer/rooms/{room.RoomID.Value}";
18+
return $@"{api.Endpoints.WebsiteUrl}/multiplayer/rooms/{room.RoomID!.Value}";
1919
}
2020
}
2121
}

osu.Game/Screens/OnlinePlay/Lounge/LoungeSubScreen.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,19 +229,19 @@ private void onListingReceived(Room[] result)
229229
if (result == null)
230230
return;
231231

232-
Dictionary<long, Room> localRoomsById = roomListing.Rooms.Where(r => r.RoomID != null).GroupBy(r => r.RoomID.Value).ToDictionary(g => g.Key, g => g.First());
233-
Dictionary<long, Room> resultRoomsById = result.Where(r => r.RoomID != null).GroupBy(r => r.RoomID.Value).ToDictionary(g => g.Key, g => g.First());
232+
Dictionary<long, Room> localRoomsById = roomListing.Rooms.Where(r => r.RoomID != null).GroupBy(r => r.RoomID!.Value).ToDictionary(g => g.Key, g => g.First());
233+
Dictionary<long, Room> resultRoomsById = result.Where(r => r.RoomID != null).GroupBy(r => r.RoomID!.Value).ToDictionary(g => g.Key, g => g.First());
234234

235235
// Remove all local rooms no longer in the result set.
236-
roomListing.Rooms.RemoveAll(r => r.RoomID == null || !resultRoomsById.ContainsKey(r.RoomID.Value));
236+
roomListing.Rooms.RemoveAll(r => r.RoomID == null || !resultRoomsById.ContainsKey(r.RoomID!.Value));
237237

238238
// Add or update local rooms with the result set.
239239
foreach (var r in result)
240240
{
241241
if (r.RoomID == null)
242242
continue;
243243

244-
if (r.RoomID != null && localRoomsById.TryGetValue(r.RoomID.Value, out Room? existingRoom))
244+
if (r.RoomID != null && localRoomsById.TryGetValue(r.RoomID!.Value, out Room? existingRoom))
245245
existingRoom.CopyFrom(r);
246246
else
247247
roomListing.Rooms.Add(r);
@@ -377,7 +377,7 @@ public void OpenCopy(Room room)
377377
joiningRoomOperation = ongoingOperationTracker?.BeginOperation();
378378

379379
if (room.RoomID == null) return;
380-
var req = new GetRoomRequest(room.RoomID.Value);
380+
var req = new GetRoomRequest(room.RoomID!.Value);
381381

382382
req.Success += r =>
383383
{

osu.Game/Screens/OnlinePlay/Match/Components/MatchChatDisplay.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private void updateChannel()
4242
if (room.RoomID == null || room.ChannelId == 0)
4343
return;
4444

45-
Channel.Value = channelManager?.JoinChannel(new Channel { Id = room.ChannelId, Type = ChannelType.Multiplayer, Name = $"#lazermp_{room.RoomID.Value}" });
45+
Channel.Value = channelManager?.JoinChannel(new Channel { Id = room.ChannelId, Type = ChannelType.Multiplayer, Name = $"#lazermp_{room.RoomID?.Value ?? 0}" });
4646
}
4747

4848
protected override void Dispose(bool isDisposing)

osu.Game/Screens/OnlinePlay/Match/Components/MatchLeaderboard.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private void fetchInitialScores()
4949
if (room.RoomID == null)
5050
return null;
5151

52-
var req = new GetRoomLeaderboardRequest(room.RoomID.Value);
52+
var req = new GetRoomLeaderboardRequest(room.RoomID?.Value ?? 0);
5353

5454
req.Success += r => Schedule(() =>
5555
{

osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ protected override ResultsScreen CreateResults(ScoreInfo score)
244244
Debug.Assert(Room.RoomID != null);
245245

246246
return leaderboardProvider.TeamScores.Count == 2
247-
? new MultiplayerTeamResultsScreen(score, Room.RoomID.Value, PlaylistItem, leaderboardProvider.TeamScores)
247+
? new MultiplayerTeamResultsScreen(score, Room.RoomID!.Value, PlaylistItem, leaderboardProvider.TeamScores)
248248
{
249249
IsLocalPlay = true,
250250
}
251-
: new MultiplayerResultsScreen(score, Room.RoomID.Value, PlaylistItem)
251+
: new MultiplayerResultsScreen(score, Room.RoomID!.Value, PlaylistItem)
252252
{
253253
IsLocalPlay = true,
254254
};

0 commit comments

Comments
 (0)