-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
Game freezes when focusing back #82
Comments
It seems that void Awake() {
Application.runInBackground = true;
} helps. But, I believe it would still allow this situation under some specific circumstances. Maybe there should be a way to limit the queue / choose what to do when the queue is full? |
Hi @SrBrahma, thanks for the feedback. The raw receive loop can be found here: NativeWebSocket/NativeWebSocket/Assets/WebSocket/WebSocket.cs Lines 641 to 702 in 4cecff9
I'm not sure Perhaps a global/static option for max queued messages could be nice. |
Sorry, I am still a beginner in C#/Unity (started less than a month ago) and i am not able to understand this or to provide a PR 😅 |
But, the thing is that Update(), that calls that dispatch, is only called when the app is focused. That's what GPT at least told me about the Update(), and that Application.runInBackground solution worked. |
I am using the snippet given in the README. On OnMessage, I do some complex and quite big data changes. I have ~20 messages per second.
The game works fine when it's focused, but when I alt-tab it, leave it there for some time, and go back, it gets frozen for a significant time. It seems that all the messages are queued while it's unfocused (as Update() doesn't seem to be happening) and then are processed when it gets focused again.
Anyway to fix this issue? It would be good if I could process the messages / call websocket.DispatchMessageQueue() outside the Update().
The text was updated successfully, but these errors were encountered: