Offline mode
Current state
- Every session must run at least one server world
- Every player must run a client world
- Every interaction between server and client is done through the transport system
- Even if client and server worlds are running on the same machine, data must be transmitted through a transport system
- There is the MemoryTransportServerSystem, which copies the data between worlds without requiring an actual network.
Problems
- Having a not networked scene to some debugging or assets edition is super annoying, while DOTSNET does not prevent you from doing that. It will throw a lot of errors every time you play the scene if you do not setup everything DOTSNET requires, even if you are not using it.
- Debugging physics is a hell. Because you cannot actually see what´s happening on the server world. Of course you can make tool for this, but why would someone do that if you can just debug by watching the physics objects ( in most cases).
- Duplicated processing. In some cases, like voxel worlds, some physic simulations, etc. there are processes whose result is required by both the client and the server, and it is way better to be runned by each world than to expect one of them to do the work and to send the whole result. So by hosting the server and running the client on the same machine, we are basically doing double work on (ironicaly) the heavy cpu things.
- Duplicated memory. Similar to the double process, both worlds need to store the results of processed data.
- Even with MemoryTransportServerSystem, these problems are not solved
Requirement
We need a way to just "shut down" DOTSNET.
This sounds like a super hard task, but actually is not. If we had a way to select which systems should run on an offline session, the problem will be practically solved already.
- The "selection" method is already written, as is what we currently use.
- Because of the way we currently select which systems run on server or client worlds, the code is already well structured, so no major changes are required to projects.
The Bootsrap class exposes both worlds, so maybe some users have made custom code relying on the access to this worlds. But this should not be a problem. In an offline mode, we could assingn both worlds as the same "Offline" world, so no major changes in users code neither.
IMPORTANT NOTE
It is possible that some users that require or will be benefited by this feature, are designing their projects in a way that is taking them away from being able to use this functionality. This is due to the current lack of such functionality. So the more time passes, the more difficult it could become to adapt to it. So it is important that this is included early in the development of this product.
I will add my use case for consideration.
- server sends voxel spawn message with a random seed.
- server procedurally generates voxel chunk to generate physics components.
- client procedurally generates voxel chunk to generate physics components. This is duplicated work if the client and server are running in the same process.
- client does client-specific stuff like generate render mesh.
I'm trying to understand the right way to have the client make use of the generation already done by the server. I may need to create my own solution, but just in case, thought I'd add the use case.
Edit: I think it's quite possible for me to take the couple of systems that do this heavy work and have them copy stuff directly from server world if they detect that it's there.
@vis2k Please say something
hey guys, sorry for late reply. DOTSNET only operates in ServerWorld and ClientWorld, which it assumes to be networked.
Can you elaborate on the use case in actual game please? I don't fully understand it yet. For example, if you buy a UI asset can't you put it into the default world and let it operate there without DOTSNET?
The thing about 3rd party assets is another issue that I don't think anybody has encountered yet, but eventually will happen.
The issue here is that while most of the time the games will run as a multiplayer session, sometimes we need to run it in an offline mode. As I mentioned in the problems list there's a lot of waste of resources, and on mobiles maybe that will be an issue. There's no reason duplicate cpu work and memory usage. Of course with a well designed project there won't be exactly double work, but it's still a waste of resources.
Also for debugging/developing/testing purposes, an offline mode is very useful.