RevenantX/LiteNetLib

NetManager.PollEvents Exception and Crash on Nintendo Switch

Vonak opened this issue · 2 comments

Vonak commented

I've got a weird crash/Exception occuring on a Nintendo Switch game, while puting the game in the background when coming back to it:

Switch crash

Attached a stacktrace showing the

_netEventsQueue.Dequeue()

call throwing an Empty Exception.
Seeing at the code of the PollEvents method and the 2 lock() sections, i can only imagine a different Thread Removing elements from the Queue, or Clear() while Shuting down due to inactivity in the background?

Right now i just tried to try/catch my PollEvent() call, and i didn't managed to reproduce the crash, but this kind of bugs are hardly easy to reproduce.

protected NetManager _netManager;
void Update()
{
     _netManager?.PollEvents();
}

Library version: [release version (0.9.5.2)]

Framework: [Unity 2021.3.12f1 Nintendo Switch platform (LiteNet sources included into the project)]

OS: [Nintendo SDK 12.3.11]

I had a similar 'queue empty' issue a while ago. In my case this was caused by a client disconnection while processing received packets. It got fixed by this commit 3f6a191
It's possible that this applies to your older library version

@Vonak should be fixed by latest LiteNetLib version 1.0.1.