Author Topic: Quick call of server stop results in editor/build freeze  (Read 6473 times)

JayJay

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Quick call of server stop results in editor/build freeze
« on: January 17, 2018, 04:40:27 AM »
Hey there,

we started using TNet for a prototype last week and yesterday I encountered freezes when I try to close the server too quickly. The worst thing about this is, that the editor isn't crashing properly, so I guess there is some weird infinite loop or a weird thread deadlock in the Stop() function of TNGameServer, I'm assuming, that Start() of the server hasn't properly finished when I call Stop().

For now I will just add a hard delay when starting up the Server I guess. Would be glad about a cleaner solution though.

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: Quick call of server stop results in editor/build freeze
« Reply #1 on: January 17, 2018, 08:30:40 PM »
If you drill through the code, you'll find that isActive is one of the last things set when using the Stop() method.  Try checking this before continuing with your flow.

However, your question is a bit confusing - why are you calling Stop() immediately after calling Start()?!

  1. TNet.TNServerInstance.isActive

JayJay

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Quick call of server stop results in editor/build freeze
« Reply #2 on: January 23, 2018, 10:32:04 AM »
Hey,

sorry for the late reply, I had my fair share of issues with Vuforia, which delayed working on the network part.

It is just something I stumbled upon, when I did some UI debugging. I would've preferred an event to register to but your solution should most certainly work better than a fixed delay, thanks.

/edit
Unfortunately TNet.TNServerInstance.isActive does not fix my problem, since it is set true straight away when the Server is started. Like I wrote this seems like a threading issue. I will take a look at the example to see whether or not the issue is on my side (which it most likely is).

/edit2
Also breaks in the example.
« Last Edit: January 23, 2018, 10:55:21 AM by JayJay »

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Quick call of server stop results in editor/build freeze
« Reply #3 on: February 10, 2018, 09:27:29 AM »
What exactly are you doing to trigger the freeze? Is it a hard freeze of the entire editor or just the game playback window? Does it ever unfreeze?
But yeah, starting and stopping the server very rapidly multiple times isn't healthy anyway: the OS has to do a lot of work to clean up those sockets. Same with file I/O. Basically anything that uses handles.

JayJay

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Quick call of server stop results in editor/build freeze
« Reply #4 on: February 21, 2018, 11:19:22 AM »
Hard editor freeze.

And I'm not talking about multiple times, I can reproduce it reliably if I stop the server withing ~3 seconds.

The problem is that this is an issue that might occur if a user accidentally opens a server by miss clicking and closes it straight away. The hard delay I set is a fine workaround for now but it's in no way a proper solution.