System.NullReferenceException: Object reference not set to an instance of an object.
Looks related to new chat display
Sentry Issue: OSU-1MK
System.NullReferenceException: Object reference not set to an instance of an object.
?, in void ChannelManager.fetchInitialMessages(Channel channel)
?, in Channel ChannelManager.joinChannel(Channel channel, bool fetchInitialMessages) x 2
?, in Channel ChannelManager.JoinChannel(Channel channel)
?, in void MatchChatDisplay.updateChannel()
?, in void MatchChatDisplay.LoadComplete()+(ValueChangedEvent<int> _) => { }
...
(7 additional frame(s) were not displayed)
An unhandled error has occurred.
First off, the stack trace is showing MatchChatDisplay. So this is a multiplayer-related issue, and as such not strictly related to the new chat overlay.
Secondly, I'm baffled at what's the null there. The implementation of fetchInitialMessages() is:
https://github.com/ppy/osu/blob/62266c72eab593476b1c4039bb717d714632fc88/osu.Game/Online/Chat/ChannelManager.cs#L369-L381
So it seems to me that the only viable null reference there is channel itself. But this should be impossible, because the channel object is getting created in the MatchChatDisplay:
https://github.com/ppy/osu/blob/62266c72eab593476b1c4039bb717d714632fc88/osu.Game/Screens/OnlinePlay/Match/Components/MatchChatDisplay.cs#L42
and then is only ever passed down the call stack. The only suspicious place to me is the recursive joinChannel() call that breaks my brain every time I read it without fail:
https://github.com/ppy/osu/blob/62266c72eab593476b1c4039bb717d714632fc88/osu.Game/Online/Chat/ChannelManager.cs#L442-L446
but looking at the joinChannel() implementation it should not be possible to have a null channel fall out of it...?
I believe the null reference is going to be api:
https://github.com/ppy/osu/blob/8f596520f3ea360cd5398fa42c762a9a3ee37e66/osu.Game/Online/Chat/ChannelManager.cs#L379
Caused by ChannelManager being Cached for access before it has potentially finished loading:
https://github.com/ppy/osu/blob/3ad1180c48c1856a5f10640d4688e4c2be25b245/osu.Game/OsuGame.cs#L854
I'm not sure it should be delayed load if we are going to be relying on it like this, but an immediate fix would be to pass in the APIAccess rather than relying on dependency injection to find it. Not sure if the rest of the class is safe to use, but maybe?
Interestingly, the reports on sentry show the user having the game running for minutes, at which point it should be loaded. Looks like CollectionManager is getting completely stuck during load. ~~I'll investigate further.~~
All users hitting this issue have 20k+ beatmaps. The game is getting stuck during loading large collections for large beatmap libraries:
https://github.com/ppy/osu/blob/6448c97929d56ef86edb13a0808c58026fdfcbf8/osu.Game/Collections/CollectionManager.cs#L229