Comments (7)
I've noticed, in latest documentation EntityReservationSystem is not mentioned at all, but I believe that's not related to this issue. It looks like something happened deep inside the command sending mechanics.
from gdk-for-unity.
The provided logs is from local managed worker, running the worker in Unity will results in immediate crash. Unity's editor log file catches nothing after "CreateEntity sent!"
from gdk-for-unity.
Hey @No3371 I'm sorry you're running into this, can you post the implementation of EntityTemplates.CreateFishTemplate
along with the schema for any components you've defined and added to this entity?
from gdk-for-unity.
Sure.
public static EntityTemplate CreateFishTemplate (string workerID, byte[] serializedArguments)
{
var template = new EntityTemplate();
template.AddComponent(new Position.Snapshot(), WorkerTypeString);
template.AddComponent(new W.C.Rotation2D.Snapshot(), WorkerTypeString); // namespace simplified
template.AddComponent(new W.F.Fish.Snapshot(), WorkerTypeString); // namespace simplified
template.SetReadAccess(WorkerTypeString, "PlayerClient");
return template;
}
The schemas:
component Fish {
id = 781;
uint32 fish_type = 1;
}
component Rotation2D {
id = 540;
float degree = 1;
}
from gdk-for-unity.
I was not sure what components are required for managed AI entities (the example project only got simulated players), so I only added Position. Did I miss anything?
from gdk-for-unity.
Hey @No3371, I managed to reproduce the problem and can see the issue:
var eTemplate = EntityTemplates.CreateFishTemplate(AWorkerConnector.WorkerType, null);
var request = new WorldCommands.CreateEntity.Request(eTemplate);
for (int i = 0; i < spawned.Length; i++)
{
request.EntityId = reserved[i];
spatialCommandSystem.SendCommand(request);
}
UnityEngine.Debug.Log("CreateEntity sent!");
Inside the WorldCommands.CreateEntity.Request(EntityTemplate template)
constructor, we serialize the EntityTemplate
into the binary format. This is native memory which is freed by the Worker SDK after Improbable.Worker.CInterop.Internal.CWorker.Connection_SendCreateEntityRequest
is finished with it. This means if we reuse the Request
object, the second time around you have memory corruption.
To fix, move the WorldCommands.CreateEntity.Request(EntityTemplate template)
constructor into the for-loop:
var eTemplate = EntityTemplates.CreateFishTemplate(AWorkerConnector.WorkerType, null);
for (int i = 0; i < spawned.Length; i++)
{
var request = new WorldCommands.CreateEntity.Request(eTemplate);
request.EntityId = reserved[i];
spatialCommandSystem.SendCommand(request);
}
UnityEngine.Debug.Log("CreateEntity sent!");
That being said, this should probably be handled more gracefully than hard-crashing the Editor! I'll raise a ticket to address that.
I've noticed, in latest documentation EntityReservationSystem is not mentioned at all
There's a small docs page on it here https://documentation.improbable.io/gdk-for-unity/docs/entity-reservation-system 😄
from gdk-for-unity.
Thanks, will try the solution!
There's a small docs page on it here https://documentation.improbable.io/gdk-for-unity/docs/entity-reservation-system 😄
I see.
The ECS Workflow -> commands section does not mentions EntityReservationSystem, that's why I said that, sorry for the reckless comment!
from gdk-for-unity.
Related Issues (20)
- MonoBehaviours with a WorkerType annotation, but no requirables, do not get enabled HOT 1
- Local launch errors on MacOS when project path contains spaces HOT 1
- Logfile location for parsing port incorrect on MacOS HOT 14
- Builds which aren't required and the user does not have build support for are not skipped HOT 2
- Schema compiler errors are swallowed by the code generator HOT 2
- The Mobile Launcher window doesn't find Android devices with hyphens in their name HOT 2
- Windows Unable to use Local Launch HOT 4
- 'NetworkConnectionType' does not contain a definition for 'ModularKcp' HOT 3
- ECS Workflow usage HOT 7
- Batch EntityID reservation HOT 2
- Feature Request: EntityCreation HOT 6
- Feature Request: Support ISharedComponentData generation HOT 4
- Feature Request: Toggling managed worker in local launch HOT 4
- Local runtime (Java) memory leak with Inspector opened HOT 7
- "Map Builder" function is undocumented. HOT 1
- SpatialOS Launcher only accept client workers named with UnityClient/UnrealClient/LauncherClient HOT 5
- Build target marked as build, but not required will fail builds if the build support is not installed HOT 1
- Deployment launcher no perms
- InvalidCastException with Coordinates field in User Defined Type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gdk-for-unity.