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

WebGL Build with Entities/ECS not working (Burst related too maybe)

Discussion in 'Burst' started by EdRowlett-Barbu, Jan 17, 2020.

  1. EdRowlett-Barbu

    EdRowlett-Barbu

    Joined:
    Mar 16, 2015
    Posts:
    88
    Unity 2019.3.0f5
    I have a scene with some GameObjects with ConvertToEntity. Basic stuff, some cubes and some spheres. The spheres have unity dots physics on them, and they just fall down on a plane at startup. This works fine in a windows build through scriptable build pipeline.

    However when I do a classic build using the scriptable build pipeline, webgl target and run it in Chrome, I get the bellow error. Any ideas?

    Tried both Entities 0.4.0 and 0.5.0, same error, see below please. How do I fix this?


    Code (CSharp):
    1. e4c48cb5-1327-488d-af3c-2c9990260db4:3436 NotSupportedException: To marshal a managed method, please add an attribute named 'MonoPInvokeCallback' to the method definition. The method we're attempting to marshal is: Unity.Entities.StructuralChange::AddComponentEntitiesBatchExecute
    2.  at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegateInternal (System.Delegate d) [0x00000] in <00000000000000000000000000000000>:0
    3.  at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate (System.Delegate d) [0x00000] in <00000000000000000000000000000000>:0
    4.  at Unity.Burst.BurstCompiler.Compile[T] (T delegateObj, System.Boolean isFunctionPointer) [0x00000] in <00000000000000000000000000000000>:0
    5.  at Unity.Burst.BurstCompiler.CompileFunctionPointer[T] (T delegateMethod) [0x00000] in <00000000000000000000000000000000>:0
    6.  at Unity.Entities.StructuralChange.Initialize () [0x00000] in <00000000000000000000000000000000>:0
    7.  at Unity.Entities.EntityManager..ctor (Unity.Entities.World world) [0x00000] in <00000000000000000000000000000000>:0
    8.  at Unity.Entities.World..ctor (System.String name) [0x00000] in <00000000000000000000000000000000>:0
    9.  at Unity.Entities.DefaultWorldInitialization.Initialize (System.String defaultWorldName, System.Boolean editorWorld) [0x00000] in <00000000000000000000000000000000>:0
    10.  at Unity.Entities.AutomaticWorldBootstrap.Initialize () [0x00000] in <00000000000000000000000000000000>:0
    11. (Filename: currently not available on il2cpp Line: -1)
    12.  
    13.  
    My build settings:



    Packages in project:
     
    Chris_Entropy and mivasiliauskas like this.
  2. Chris_Entropy

    Chris_Entropy

    Joined:
    Apr 11, 2011
    Posts:
    202
    Having the same issue. It works fine in the Editor, but crashes with the error message above in WebGL.
     
    deus0 likes this.
  3. Sarkahn

    Sarkahn

    Joined:
    Jan 9, 2013
    Posts:
    440
    As far as I know webgl with ecs just isn't supported yet, theres been a couple threads about it. You could use Project Tiny instead since it's being developed from the ground up with web/mobile in mind.
     
  4. craftx

    craftx

    Joined:
    Oct 2, 2018
    Posts:
    13
    Had the same issue. Ended up downgrading the Entities package to 0.3.0 to avoid this exception. There are still other issues preventing it from working though (getting "memory access out of bounds,RuntimeError" all over the place).
     
    deus0 likes this.
  5. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    I recommend using Project Tiny if you need DOTS + WebGL. That's the optimized platform for web development with DOTS. Small package and fast loading.

    I am not familiar with the entities package errors, but I can confirm that hybrid.renderer package needs features that are not supported by base WebGL, such as GPU instancing. WebGL 2 added GPU instancing support, but currently Apple browsers don't support WebGL 2. We are waiting for future advances in browser API support before we decide when the high end DOTS hybrid.renderer browser support is added, and whether WebGL2 or WebGPU is the right choice for us.
     
    Rallix, MNNoxMortem, DrViJ and 4 others like this.
  6. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    Hi Sebastian, what is the current state of DOTS + WebGL.
    Cheers
     
    deus0 likes this.
  7. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    I am also wondering. Is there many code differences between ECS normal and tiny? Most my systems are using ScheduleParallel, so if its the same code I could convert my project, in order to hit WebGL too.
     
  8. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    Any ETAs on when Entities package will be working with WebGL? In fact it hasn't been updated in an entire year..!
     
    Deleted User and lclemens like this.