Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Other [0.8.4] Latios Framework for ECS megathread

Discussion in 'Entity Component System' started by DreamingImLatios, Dec 21, 2019.

  1. Bivens32

    Bivens32

    Joined:
    Jul 8, 2013
    Posts:
    36
    Are you planning on adding any features that allow for workflows like in this video?

    It has some very interesting animation techniques if you haven't seen it. Particularly around the 7 minute mark. Being able to blend between 2 animation poses using linear, bezier, bicubic, or other custom interpolations would be great.
     
    DreamingImLatios likes this.
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Yes! Kinemation's goal is to provide the building blocks to do exactly these things and more!

    It might be important to note I don't plan on writing the visual editing experience for all these workflows though, at least in the nearer term. Ultimately you are going to have to write the code that chooses how to mix animation keyframes and procedural curves and all. But Kinemation will provide a bunch of utilities to make that code as easy to write as possible. And then you will be able to jump into play mode and animate directly against that code so you can find poses that react well to those spring interpolations as your character navigates in your game world.
     
    Bivens32 and Occuros like this.
  3. ChrisPie

    ChrisPie

    Joined:
    Mar 5, 2015
    Posts:
    31
    Have you checked if latios works with NetCode package? NetCode has a custom injection script, so I imagine it would need to be adapted to latios's injection?
     
  4. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    I know the bootstrap templates are incompatible. Beyond that though, I haven't really tested it nor plan to for any of my personal work. This may provide a starting point if you are interested in trying to get this to work, although you may have conflicts with the LatiosInitializationSystemGroup conflicting with the Client/ServerInitializationSystemGroup. https://github.com/Dreaming381/Lati...mentation~/Core/Customizing the Bootstraps.md

    Out of curiosity, what parts of the Latios Framework do you want to use in your Netcode project? Some might be easier to make work than others.
     
  5. ChrisPie

    ChrisPie

    Joined:
    Mar 5, 2015
    Posts:
    31
    Mostly core helpers, blackboard entity, the convenient syncpoint, and audio if possible.
     
  6. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Alright. Yes. You are going to have to resolve that InitializationSystemGroup conflict. The good news is that I think it is possible and if you do it, Myri will just work. Keep in mind that I haven't tested any of what I am about to write, so there may be some unexpected issue.

    Anyways, ClientServerBootstrap is public and Initialize() is virtual, so you can subclass it and override it with a custom bootstrap. Every World will need to be a LatiosWorld instead. Creating a LatiosWorld will automatically generate a LatiosInitializationSystemGroup, LatiosSimulationSystemGroup, LatiosPresentationSystemGroup, and DestroyEntitiesOnSceneChangeSystem. Remove those from the world immediately after creating the world. Anything that uses hierarchical system culling will now need to be in a RootSuperSystem.

    You will need to create several RootSupersystem subclasses with [UpdateInGroup(typeof(InitializationSystemGroup))] and EnableSystemSorting set to false inside CreateSystems(). You'll need the following:
    • A group that updates before BeginInitializationEntityCommandBufferSystem and OrderFirst = true. This group adds PreSyncPointGroup in CreateSystems.
    • A group that updates after BeginInitializationEntityCommandBufferSystem and OrderFirst = true. This group adds SyncPointPlaybackSystem and SceneManagerSystem in that order.
    • A group that updates after Unity.Scenes.SceneSystemGroup. This group adds LatiosWorldSyncGroup.
    That should be everything you need for Injection Workflow. Explicit Workflow requires a few more steps.

    Let me know how it goes!
     
  7. ChrisPie

    ChrisPie

    Joined:
    Mar 5, 2015
    Posts:
    31
    Thanks for that. I tried it and I'm getting
    System added twice: Latios.Myri.Systems.AudioSystem
    and
    System added twice: Latios.Systems.MergeBlackboardsSystem
    . Probably because I have both server and client world in the Editor.
    Also getting warnings about systems not being in expected group:
     
    Last edited: Sep 29, 2021
  8. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    It is unclear if that error is coming from the runtime or the Entity Debugger. The latter is a Unity bug, as a system showing up in multiple groups is perfectly valid in the runtime. I often get these errors when I run the TransformSystemGroup a second time after playing back command buffers.

    MergeBlackboardsSystem is generally pretty harmless if it runs more than once as long as you are aware of it. However, Myri is a bigger concern. You only want that to run on "fat clients", that is clients that have rendering enabled. So you will have to filter out that system on thin clients and servers. There's one caveat, and that's that Auto Destroy on Finish won't work on audio sources on the server. Ideally entities that use that are "presentation only" and only run on fat clients, since the behavior is nondeterministic. Be extra careful with these, because the last AudioSystem to be created will grab the audio driver and probably kick off the others. It will free it when destroyed, but the driver won't be returned to the original owner.

    That suggests that things are likely in the wrong spots still. If you can share the system order hierachy captured from the Entity Debugger (make sure to show inactive systems), then I can better help you assess whether or not this is a real issue and if so how to resolve it.
     
  9. ChrisPie

    ChrisPie

    Joined:
    Mar 5, 2015
    Posts:
    31
    The errors are from the Unity.Entities.Editor, so the new version of EntityDebugger.
    For audio, I don't need it on the server, so I can probably delete AudioSystem on both server and thin clients.
    The warnings make sense for me, you can't UpdateAfter a system from another group, and you're trying to do

    Code (CSharp):
    1. [DisableAutoCreation]
    2.     [UpdateInGroup(typeof(LatiosInitializationSystemGroup), OrderFirst = true)]
    3.     [UpdateAfter(typeof(BeginInitializationEntityCommandBufferSystem))] // this one's in
    4. InitializationSystemGroup
    5.     public class SyncPointPlaybackSystem
    Here's the initialization part of hierarchy:
    upload_2021-9-29_17-45-55.png
     
    DreamingImLatios likes this.
  10. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Yes. They share the same broken logic. Seems harmless.
    Yes. Just make sure you filter out the type prior to injecting systems rather than destroying it later.
    Weird. I would have thought that adding
    EnableSystemSorting = false;
    to LatiosPreSync, LatiosSyncPointPlayback, and LatiosWorldSync (the parent versions you created) would have made those warnings go away. Regardless, you have the right system order for clients, which is a really good sign!
     
  11. ChrisPie

    ChrisPie

    Joined:
    Mar 5, 2015
    Posts:
    31
    Makes sense. Sorry for wasting your time as I might end up giving up on Latios for NetCode because it feels like a lot of trouble for a couple of features I'd use. I changed 1 of my systems to :SubSystem to check if blackboard and sync point work. Does this call stack tell you anything?
    Code (CSharp):
    1. InvalidOperationException: Error: Calling Update on a SubSystem from within another SubSystem is not allowed!
    2. Latios.LatiosWorld.BeginDependencyTracking (Latios.SubSystemBase sys) (at Packages/com.latios.latiosframework/Core/Core/Framework/LatiosWorld.cs:186)
    3. Latios.SubSystemBase.OnUpdate () (at Packages/com.latios.latiosframework/Core/Core/Framework/SubSystem.cs:40)
    4. Unity.Entities.SystemBase.Update () (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/SystemBase.cs:412)
    5. Latios.SuperSystem.UpdateManagedSystem (Unity.Entities.ComponentSystemBase system) (at Packages/com.latios.latiosframework/Core/Core/Framework/SuperSystem.cs:114)
    6. UnityEngine.Debug:LogException(Exception)
    7. Latios.SuperSystem:UpdateManagedSystem(ComponentSystemBase) (at Packages/com.latios.latiosframework/Core/Core/Framework/SuperSystem.cs:134)
    8. Latios.Systems.LatiosInitializationSystemGroup:OnUpdate() (at Packages/com.latios.latiosframework/Core/Core/Systems/LatiosInitializationSystemGroup.cs:45)
    9. Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/ComponentSystem.cs:114)
    10. Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/ComponentSystemGroup.cs:472)
    11. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/ComponentSystemGroup.cs:417)
    12. Unity.NetCode.ServerSimulationSystemGroup:OnUpdate() (at Packages/com.unity.netcode@0.6.0-preview.7/Runtime/ClientServerWorld/ServerSimulationSystemGroup.cs:75)
    13. Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/ComponentSystem.cs:114)
    14. Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/ComponentSystemGroup.cs:472)
     
  12. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Dang it! I was supposed to improve that error message for 4.1 and totally forgot. So there's a second reason that error appears besides the reason it gave. If a previous SubSystem threw an exception and exited, it skips a dependency management cleanup step and the next SubSystem encounters the lingering state and throws that error. Most likely, there is some other error in your log that is likely the culprit.

    Also, regardless of if you use the framework in the future, you aren't wasting my time. I've even learned a few things from your attempt so far, which is incredibly valuable! :)
     
    ChrisPie likes this.
  13. ChrisPie

    ChrisPie

    Joined:
    Mar 5, 2015
    Posts:
    31
    Ooh, ok. Yeah, there's a null reference exception on

    latiosWorld.syncPoint.CreateEntityCommandBuffer().AsParallelWriter();

    the syncPoint is null, probably because you only set it to result of GetExistingSystem in the world constructor. Should I set the setter in the LatiosSyncPointPlayback group you told me to add?
    edit: I changed to

    latiosWorld.syncPoint = GetOrCreateAndAddSystem<SyncPointPlaybackSystem>();

    and it seems to work fine now
     
    DreamingImLatios likes this.
  14. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    This issue is probably specific to how you set up the bootstrap, but your workaround is totally valid. I'm glad you got it working! :) That's no small feat! :cool:
     
  15. ChrisPie

    ChrisPie

    Joined:
    Mar 5, 2015
    Posts:
    31
    Would it possible for you to expose another constructor for LatiosWorld, that apart from the name takes the World flag and passes it to base? I had to change your code, because NetCode expects the "Game" flag.
     
  16. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Yes. That's a very trivial fix and I should be able to get a patch release for it up today or tomorrow. Besides that and the error message, are there any other minor improvements you would like to see in this patch?
     
  17. ChrisPie

    ChrisPie

    Joined:
    Mar 5, 2015
    Posts:
    31
    Unfortunately I'm not sure how to do that, any ideas? No other feedback for now. I'll let you know if something comes up.
     
  18. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Assuming you copied CreateServerWorld and replaced the World construction part, then down below, there should be a
    world.GetOrCreateSystemsAndLogException
    . Right before that, you want to find inside of allManagedTypes the type Latios.Myri.Systems.AudioSystem and remove it.
     
  19. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Hey everyone!

    I have good news and bad news.

    The bad news is that Latios Framework 0.5 will probably be a while yet.

    The good news is that I finally have a prototype of Kinemation's skinning which I am ready to show.

    https://github.com/Dreaming381/Kinemation-Skinning-Prototype

    The project has a toggle that lets you switch between Hybrid Renderer and Kinemation skinning (don't touch it while in play mode).

    There's a few things I would love feedback on:
    • Does the project run well (or at all) on your target hardware?
    • Are you comfortable with Kinemation hijacking the Hybrid Renderer so extensively?
    • Are there any features or use cases I am overlooking (not mentioned in the README) which you deem too important to be omitted in the initial release?
    • Do you have any suggestions for further optimizations?
    Also, there's a ton of advanced ECS stuff involved in this prototype. If you have questions regarding any of it, don't hesitate to ask.
     
  20. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    347
    It's GPU or CPU skinning?
     
  21. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,592
    By reading docs, is GPU. But lot of stuff is calculated on CPU. I.e. Culling.

    Interisting docs reading. Haven't look into code however.
    One thing I didn't notice, when flying through doc is, how many bones has each dancer?
    Does having many different skinned meshes and bone structures can affect performance? That assuming bouns count per mesh stays the same.

    How much faster in your benchmark, is optimised skinning using buffers, vs entities based exposed version? Both approaches operates on indexes right. (buffer vs entity) ?

    Can your system update skeletons, when culled?
    Do you use unity culling group solution, or your own?

    What will be the bottleneck and for how many dancers, when framerate drops below 60fps on your hardware?
     
    DreamingImLatios likes this.
  22. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    347
    I'm asking for skinning alone as I've done GPU skinning a few weeks back and I'm looking for more references/inspirations. Sadly, I've done it as PoC for my company so I could not show anything substantial here. But I'm planning to upgrade it and use it privately.

    I have only simple animation playing but using a model with 50 bones / 5,5k vert / 3k tris I've gotten 100k objects on empty scene in 5fps. And almost all of that time was a DrawMeshInstancedProcedural call. The cost of drawing consists of sending a float4x4 (localToWorld) and an int as a current animation frame. Planning to upgrade it to float4x4 and int4+float4 as animation blending values.

    All animation calculation is done on the CPU side so I can have animation events and don't need to calculate skinning in hidden objects. I think about adding "single bone skinning" on the CPU for attachment purposes.

    I'm also wondering about which optimizations and blending algorithms should I implement as I'm not so much versed in these topics.
     
    DreamingImLatios and Antypodish like this.
  23. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,592
    I also developed custom solution for skinning, as Unity bottlenecks at 10k, as noted by OP in the documentation.

    However, we are required to calculated most of bones, even if they are culled. The reason is, regarding for our RTS units aiming solution. However, yes we got mostly fewer bones than 50 per units.

    We use also HDRP and drawMesh approach, rather than Hybrid Renderer V2.

    Also we allow some bones not need to calculate, when not rendering.

    It is interesting to see various solutions from our fellow developers.

    And you would be thought, that native DOTS solutions should be most optimal :rolleyes:
     
    adammpolak and DreamingImLatios like this.
  24. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    347
    When DOTS would be released I assume a lot of things would be more optimal.
    And we need to remember generic solution of the problem almost never be as optimal as a custom-made tool exactly made for the problem it wants to solve.

    That's why I have my "single bone skinning". I can calculate only the bones I need to or I should say only get its matrix as all I need is the id of bone, animation, and current frame because I baked everything into an array.
    I wonder now if my solution is correct and would work with blending or just had luck with bone being in object position.
     
    Antypodish likes this.
  25. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,592
    I don't see reason why blending wouldn't work in your case. Is about interpolating between two arrays of bone transforms right? If I understand the explanation right, I am sure you would be good.
     
    Krajca likes this.
  26. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    22
    The main thing is that all meshes bound to the same skeleton are designed for that skeleton layout. There's no "retargeting" in that sense. But otherwise, you'll see a slight increase in cost with lots of different meshes since there are more blobs to potentially look up and the meshes might fragment chunks. This impact will be pretty minimal compared to the number of bones to process. A lot of the complexity gets handling by the reactive binding system.

    Exposed no Blending Dev Build
    upload_2021-11-21_16-13-49.png

    Optimized no Blending Dev Build
    upload_2021-11-21_16-6-41.png
    Keep in mind I run the Transform system twice so that I can get the world-space positions of the feet and snap them back (which matters when blending is enabled). So that hurts the exposed bones by quite a bit. A lot of the small jobs in the middle is my multi-job transform hierarchy update optimization, which processes each depth level separately.

    You'll also see a much larger hit in the culling callbacks. The first large job is bone culling. The second large one is the buffer writes which has to do the random accesses to gather the bones. The third and forth large jobs are just bone culling, as the buffer writing job skips a bunch of work it already did.

    Also, I have no idea why the Hybrid Renderer thinks it needs to complete the ExposedBoneBoundsJob. So I still have some scheduling gaps to remove.

    Updating skeletons is completely user-side. This system just looks for changes in the transforms to update bounds, and then frustum culling just skips GPU-specific work. You have to implement not updating skeletons outside the frustum yourself.
    I'm using a solution very similar to what the Hybrid Renderer does. For anything that gets Frustum culled, I have chunk bounds and per-entity bounds. And I encode the passed in culling planes from the culling callback into PlanePacket4 and use a combination of Intersect2 and Intersect2NoPartial. The big difference is that I am culling skeletons rather than RenderMesh instances, but it is otherwise the same technique. I'm hoping that with splitting up culling into multiple systems that I could have user-defined culling. That still needs some refactors and users requesting such a feature.
    For exposed bones there is not a lot of headroom left. Bone count is the biggest factor.
    For optimized skeletons, Unity derps out and decides to just not draw anything when the deform buffer gets to some magic size. This happens for the Hybrid Renderer too, although the Hybrid Renderer can handle more entities before it happens. Here's what 20k optimized entities with no blending looks like on the CPU though:
    upload_2021-11-21_16-35-23.png
    So my solution is true CPU-driven skeletal animation where all bones are computed on the CPU. Most game engines usually cap out at 1000 of these. I'm pushing well past that. But at some point, animation textures is just outright faster. I'm guessing that's what you are doing.
    I suspect their internal version is significantly faster than what we have. It will be interesting to compare if they ever release it.
    I'm not sure that applies in this case though. Once I remove some prototype hacks which should have minimal impact on performance, this system will be pretty generic.
     
    Krajca and Antypodish like this.
  27. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,592
    DreamingImLatios likes this.
  28. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    347
    Yeah but instead of textures, I have SO with an array of data. And I just save per bone data instead of per pixel. It's less data but more calculations on the GPU side.
     
  29. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    New video for you as we all wait for 0.50.



    As always, leave your thoughts, feedback, and questions!

    2022 is going to be a crazy year!
     
  30. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    825
    Seems like a bug with 0.4.2 & Myri and subscenes:
    When a project is built and run as standalone - audio doesn't appear to work when audiosources are placed in subscenes or on prefabs which are on subscene entities.
     
  31. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Here's what I did:

    1) Opened ECSSamples and opened Hello Cube - 3 SubScenes scene in Unity 2020.3.25f1.
    2) Added Latios Framework via Package Manager.
    3) Created a Latios Framework Bootstrap - Injection Workflow.
    4) Commented out Unity's virtual memory bootstrap (it only checks for a particular scene which isn't this one).
    5) Imported a looping audio clip.
    6) Opened the subscene.
    7) Added an empty GameObject to the subscene with a Myri audio listener and set the position to (-2, 0, -2).
    8) Added a Myri audio source to the cube and set it to looping, 5 voices, and assigned the audio clip.
    9) Entered play mode. Everything is working as expected.
    10) Made a build.

    At this point, I got errors regarding Burst for ParentSystem/GatherChildEntities. Eww.

    11) Tried again. Successful build this time.
    12) Ran built file.

    I got no audio and no spinning cubes at all. This was a development build and there was no log info. Just the skybox.

    Anyways, after some logging and debugging, I discovered a regression in the engine's execution order that causes the Latios Framework's scene management to conflict with Unity's subscene management. So as a temporary fix, I added these two lines to the bootstrap before the system sorting:
    Code (CSharp):
    1.         world.GetExistingSystem(typeof(Latios.Systems.SceneManagerSystem)).Enabled                 = false;
    2.         world.GetExistingSystem(typeof(Latios.Systems.DestroyEntitiesOnSceneChangeSystem)).Enabled = false;
    13) I removed the Myri components and made a build, and I got the spinning cubes to render.
    14) I added the Myri components back and made another build.

    And I suspect this might be where you ran into an issue, or maybe you got further than me. But I got the imfamous:
    However, the more relevant error is as follows:
    Code (CSharp):
    1. Could not open file C:/Users/tyler/Documents/Unity Projects/Test Projects/EntityComponentSystemSamples/ECSSamples/Builds/Win64-Build/Samples_Data/StreamingAssets/SubScenes/eee6dacb0839c4d348d7a155127cebe7.entityheader for read
    2. IOException: Failed to read from C:/Users/tyler/Documents/Unity Projects/Test Projects/EntityComponentSystemSamples/ECSSamples/Builds/Win64-Build/Samples_Data/StreamingAssets/SubScenes/eee6dacb0839c4d348d7a155127cebe7.entityheader!
    3.   at Unity.Entities.Serialization.StreamBinaryReader.ReadBytes (System.Void* data, System.Int32 bytes) [0x0009d] in C:\Users\tyler\Documents\Unity Projects\Test Projects\EntityComponentSystemSamples\ECSSamples\Library\PackageCache\com.unity.entities@0.17.0-preview.42\Unity.Entities\Serialization\BinarySerialization.cs:162
    4.   at Unity.Entities.Serialization.BinaryReaderExtensions.ReadInt (Unity.Entities.Serialization.BinaryReader reader) [0x00001] in C:\Users\tyler\Documents\Unity Projects\Test Projects\EntityComponentSystemSamples\ECSSamples\Library\PackageCache\com.unity.entities@0.17.0-preview.42\Unity.Entities\Serialization\BinarySerialization.cs:70
    5.   at Unity.Entities.BlobAssetReference`1[T].TryRead[U] (U binaryReader, System.Int32 version, Unity.Entities.BlobAssetReference`1[T]& result) [0x00001] in C:\Users\tyler\Documents\Unity Projects\Test Projects\EntityComponentSystemSamples\ECSSamples\Library\PackageCache\com.unity.entities@0.17.0-preview.42\Unity.Entities\Blobs.cs:449
    6.   at Unity.Entities.BlobAssetReference`1[T].TryRead (System.String path, System.Int32 version, Unity.Entities.BlobAssetReference`1[T]& result) [0x00027] in C:\Users\tyler\Documents\Unity Projects\Test Projects\EntityComponentSystemSamples\ECSSamples\Library\PackageCache\com.unity.entities@0.17.0-preview.42\Unity.Entities\Blobs.cs:476
    That's the error with the latest Entities patch. Without the patch I got a slightly different error, but still the same issue which is that deserializing the blob assets that Myri uses is failing. In this particular error, it is looking for a file in the StreamingAssets folder which as it turns out isn't getting generated in the build. I'm sure there's a forum thread on this which tracks this issue down. But I don't have much time to look into it more tonight.

    The Latios Framework doesn't interact with the build process in any way and only uses the official BlobAssetComputationContext workflow for generating blobs. While I am aware of bugs in the blob asset conversion for Myri, those are related to missing dependency declarations for live link and aren't related to this. Especially since in play mode I am loading the closed subscene just fine. So it is definitely a build process issue, and definitely a Unity bug. But I will still keep digging!

    Edit: I tried something really stupid and created a StreamingAssets folder in the Assets folder. I left if completely empty and made a build. And audio is now working!

    Hopefully this helps, otherwise I will probably need a repro project or process to further troubleshoot your issue.
     
    Last edited: Feb 16, 2022
  32. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    825
    Thanks for the followup! So I use Myri outside of the separated from the framework so I cant speak to any issues regarding ParentSystem/GatherChildEntities. I'm not entirely sure but this might have existed since 3 as I was using Myri a while ago, ran into issues(no audio) in a build at the time. I gave up as I thought it was the changes from separating it from the framework that was the cause. But then with so much time waiting around for 0.50, thought Id give it a more thorough try.

    Anyway the final error you highlighted is basically what I am getting as well. I wonder if its at all related to https://issuetracker.unity3d.com/is...-a-second-time-fails-if-there-are-blob-assets / https://forum.unity.com/threads/the...valid-serializing-deserializing-world.920039/ which has been a long standing issue. Really hoping its something far simpler though!
     
  33. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Yeah. If you get it working in play mode, then you probably got it working. It is just the command buffers and the audio settings component that are framework specific. I considered separating it out myself but decided I didn't want to maintain two versions. I'm more than willing to support anyone who wants to own that effort though!

    As for subscenes and scene management, I know it was working properly at one point, but I don't test that frequently partly because of all the bugs with subscenes and partly because subscene conversion disables Burst which makes Blob Asset conversion awfully slow.

    I did resolve that issue. I'm not sure if it was from adding the StreamingAssets folder or just the sequence of actions I took that fixed some other issue. But keep me posted if you get it to work!
     
  34. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    825
    I guess the edit was made while I was typing my response :), but even with an empty StreamingAssets folder I still get issues. Ive uploaded the fireworks demo with a subscene that has some looping AudioSources, it uses the unmodified latiosframework, I wasn't sure where to put the two lines in the bootstrap as I was getting errors appending them towards the bottom of the latios bootstrap - so it doesn't have those fixes.

    Strangely enough, in this there aren't the previous header errors, it just silently doesn't have subscene audio.
    While the console doesn't spit out any errors, the player log does report this:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2.   at Unity.Scenes.ResourceCatalogData.GetGUIDFromPath (System.String path) [0x00096] in <eb4b536963bd442fad8c533155890ba9>:0
    3.   at Unity.Scenes.SceneSystem.GetSceneGUID (System.String scenePath) [0x0000b] in <eb4b536963bd442fad8c533155890ba9>:0
    4.   at Unity.Scenes.GameObjectSceneUtility.AddGameObjectSceneReferences () [0x00034] in <eb4b536963bd442fad8c533155890ba9>:0
    5.   at Unity.Entities.AutomaticWorldBootstrap.Initialize () [0x0000c] in <beae90769cf04ff68fdfb91322cab071>:0
    The repro project can be found at https://github.com/thelebaron/bug_myri_subscene/tree/main/LatiosFireworksDemo
    Theres a simple menu script I added to reduce clicks for project building in the menus(ProjectBuilder>Build), it references the game.buildconfiguration asset inside of Packages/com.junk.buildtools.

    edit: Added a second repro, this case its myri separated from latios framework. Project is similar two subscenes of audiosources, this time with the same entity header errors.
    Ive found some odd behaviour, occasionally after just moving sources in and out and then back into a particular subscene, the project might build and audio may work. But it seems like its cached result of having audio outside of a subscene(when it is actually inside), and making a brand new subscene with audio and a new build will trigger the errors again. Not really sure if I'm just losing my mind with it or what.
     
    Last edited: Feb 16, 2022
  35. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    That's likely the execution order bug. For some reason the active scene change event is being generated after the first subscene loading entity is created, and that confuses the framework scene manager. Those two special lines fix it, but only if the project doesn't depend on those systems. The fireworks demo does. I'm going to try and fix that bug this weekend, though it won't affect your use case at all.

    I will play with that and see if I can figure out something consistent. Something that would be super helpful is if you also use Unity Physics colliders in the project, if you run into similar issues with those. I would expect similar behavior, since those also use blobs.
     
  36. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    825
    I do use Unity Physics colliders in my main project, no errors in regular use unless attempting to serialize/deserialize them to disk(leads to the bug report I linked), though I'm not attempting to do any of that currently, nor do I do that with any audio.
     
    DreamingImLatios likes this.
  37. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Update:

    This is actually an editor/engine bug and I am submitting a bug report as I am typing this. Here's the culprit in AssetImportWorker#.log:
    Code (CSharp):
    1. [Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Scenes.Editor/SubSceneImporter.cs line 144]
    2.  
    3. Fatal Error! Unable to initalize any audio device (even FMOD nosound device), please check your audio drivers and/or hardware for malfunction
    4. UnityEngine.AudioClip:GetData (single[],int)
    5. Latios.Myri.Authoring.Systems.ClipsAndListenersConversionSystem/<>c__DisplayClass2_0:<ConvertBatchedClips>b__0 (Latios.Myri.Authoring.AudioSourceAuthoring) (at Packages/Latios-Framework/MyriAudio/Authoring/ClipsAndListenersConversionSystem.cs:54)
    6. Unity.Entities.EntityQueryBuilder:ForEach<Latios.Myri.Authoring.AudioSourceAuthoring> (Unity.Entities.EntityQueryBuilder/F_C`1<Latios.Myri.Authoring.AudioSourceAuthoring>) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/EntityQueryBuilder_ForEach.gen.cs:230)
    7. Latios.Myri.Authoring.Systems.ClipsAndListenersConversionSystem:ConvertBatchedClips () (at Packages/Latios-Framework/MyriAudio/Authoring/ClipsAndListenersConversionSystem.cs:48)
    8. Latios.Myri.Authoring.Systems.ClipsAndListenersConversionSystem:OnUpdate () (at Packages/Latios-Framework/MyriAudio/Authoring/ClipsAndListenersConversionSystem.cs:27)
    I'm not sure what else I can do about this, so do me a favor and bring awareness to this issue!
     
    thelebaron likes this.
  38. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    825
    Does this just get logged during subscene conversion? I dont recall seeing this before
     
  39. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
  40. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    825
  41. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Ah. Here's what I did exactly:
    1) Opened your isolated Myro repro project (not the fireworks).
    2) Entered play mode, and ensured audio worked there.
    3) Made a development build by modifying your predefined build profile. Saw the build was missing some subscene files in StreamingAssets.
    4) Noticed you weren't using the latest patch release of Entities. Updated that via package manager.
    5) Repeated steps 2 and 3.
    6) Went into the logs. At this point I had both Log #0 and Log #1. I investigated the end of Log #1 to find the error.

    I'm on Windows 10 by the way.

    If you are still struggling, I'm usually available afternoons and nights in US time on weekends (including Monday this weekend) and would be willing to get on a Discord call and help you troubleshoot this. PM me if that's something you are interested in.
     
  42. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    0.4.3 is out, which should hopefully solve the subscene bugs that were my fault.

    As for Unity's bug, here's the case number and title:
    1404129 - AssetImportWorker crashes in AudioClip.GetData(). Unable to initialize audio device.
     
    Krajca likes this.
  43. Endlesser

    Endlesser

    Joined:
    Nov 11, 2015
    Posts:
    85
    Hi Latios, I've been using Myri for my project as dots audio solution since last month, and there are 2 issues I'd like to ask about, nothing serious.

    1. There is error log when instantiate an entity prefab with one shot audio source(mostly is less than 1 sec), it says something out of range in Myri. This happens occasionally and make no audio impact or performance impact, so is OK I think.
    upload_2022-3-9_17-25-7.png

    2. When instantiate an entity prefab with looped audio source, the playback start position is not 0:00(always start at a offset, and setting voices change its position but still not 0:00), reset playback state seems has no effect on it. I read all Myri guides on Github but can't figure out why.

    Btw, I'm using Injection workflow and setting `DestroyEntitiesOnSceneChangeSystem``SceneManagerSystem` disabled.

    Myri ver 0.4.3
     
  44. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Amazing bug report! This actually exposed several bugs which I need to fix this weekend. In the meantime, if you append
    + itdMaxOffset
    to line 63 of Sampling.cs, that will hopefully resolve the main issue.

    The reason is because I overlooked the use case of "starting a loop from the beginning on command". When a looped source starts playing, it picks where to play based on the global DSP clock and ignores when it was instantiated. This is necessary when you have lots of looping ambient sources in a complex scene. But in your case it isn't what you want. I will investigate what it takes to support your use case and maybe have a solution this weekend. But this might require a breaking change and need to wait for 0.5.
     
    Endlesser and Occuros like this.
  45. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    Good news!

    0.4.4 is out!

    I got the ITD indexing bugs fixed. And I also found a way to add the alternate playhead mode to looping sources without any API-breaking changes.

    Keep the Myri feedback coming! I'd love to hear what you all do with it! :D
     
    Occuros likes this.
  46. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    There have been 9 feature and bugfix releases since the last DOTS compatibility release. That ends today!

    Latios Framework 0.4.5 is out!

    Now you can use collection components, FindPairs, and Myri audio with the updated packages!

    This is a compatibility release, meaning there aren't any new features or API changes, with one exception:

    ISystem is now supported, and there's some new extensions and functionality to make it work with existing Core features. This new version of DOTS also allowed me to better address lingering issues. I've documented all of it in the Changelogs inside the documentation folder.

    LSSS has also been updated to make use of ISystem in as many places as possible. That's currently the best place to look for examples of the new ISystem support.

    What's Next

    DOTS 0.50 is pretty close to best-case scenario regarding Latios Framework development. A bunch of deeply internal bugs and missing API have been addressed. I can finally use new Burst instrinsics. DSPGraph got a Burst compatibility update so Myri can remain viable. And the Hybrid Renderer made not many changes to the areas that affect upcoming Kinemation development.

    I could spend a ton of time on Core improvements and optimizations across the framework, I feel there is a big task I need to fulfill. With the removal of hybrid components and lack of compatible animation packages, Kinemation is needed more than ever. And if you are desperate for a solution, I encourage you to reach out to me.

    Most of the other Latios Framework 0.5 features are complete. So hopefully I will be able to get 0.5 out the door in the next month or two. And after that, I would love to hear your opinions on what you would like to see prioritized!

    But until then, try out 0.4.5 and report any issues and feedback!

     
    Occuros, FONTOoMas and Fribur like this.
  47. Endlesser

    Endlesser

    Joined:
    Nov 11, 2015
    Posts:
    85
    I couldn't agree more.

    At the time between Entity 0.51 ~ 0.10, there is very likely I'm going to take Kinemation in my project, since DOTS anim is what I've been using for like 2 years and most works are done, for the circumstances of now I'd rather leave it intact as low level and improve it to suitable place when the time comes.

    I will give as much feedback as I can, and if there is any asks about DOTS anim, feel free to contact me, perhaps I can help.
     
    DreamingImLatios likes this.
  48. DrBoum

    DrBoum

    Joined:
    Apr 19, 2020
    Posts:
    26
    if kinemation would support the use of animation clips, i would use it right away.
     
  49. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,993
    I'll be honest, if you liked DOTS animation that much, you may not like Kinemation. The first release is going to be very foundational, meaning no state machine, graph, retargeting, IK, or any of that sort. My goal is to build the API such that users can build an Animator Controller equivalent, or a Playables equivalent, or a DOTS animation equivalent, or some other equivalent on top of Kinemation.

    This is 100% planned in the first release. It's a big part of why Kinemation is taking so long to develop (though it just got a fair bit easier with the latest DOTS fixing BlobArray alignment). I'm wrapping ACL (really awesome DoD-friendly AAA animation compression) in a native plugin and storing its compressed state in blob assets. The whole ecosystem will run in Burst.
    _________________________________________

    Anyways, if people really want this, there are ways to help me release it faster. I don't expect anyone to help me write the ECS state management, binding systems, blob manipulation,, or rendering logic. But there are other pieces to the puzzle which I feel may be more accessible:
    • Bindings AssetPostProcessor - entirely classical Unity stuff
    • Test character assets - modular is preferred to validate workflows and runtime bindings support
    • Unity Physics ragdoll test scene - for as much as I don't like Unity Physics, I'm fairly confident people want this and I believe I can easily support it, but need help setting up the test
    • GitHub Workflow - CI/CD for packaging the native plugin
    • Testing - Custom compute shaders and native plugins add a lot of volatility to platform support and I don't have all the platforms you may want to deploy to
    If you would like to contribute to any of these, please reach out!
     
  50. Endlesser

    Endlesser

    Joined:
    Nov 11, 2015
    Posts:
    85
    I see.

    Gladly u have so much ambitious on it, and please don't get any pressure from me or any Kinemation enthusiast, like I said I've already completed present anim works of my proj, performance and easy-to-use are the features I'm looking for in the next anim phase.

    Just go with your own pace and do whatever preferable.

    I'll check those as soon as I finished audio works and feedback of Myri.
     
    DreamingImLatios likes this.