#Stuck with LoadSceneAsync

1 messages · Page 1 of 1 (latest)

jovial kite
#

Hello there, I am stuck. The following code used to work perfectly with 1.0.0-pre.1 but the while loop neve rends with 1.0.0-pre.65. Any suggestion is appreciated otherwise I will be better of reverting to the previous version

           var sceneGuid = SceneSystem.GetSceneGUID(ref customWorldUnmanaged.GetExistingSystemState<SceneSystem>(), "Assets/Scene/CombiningBehaviours/Prefabs.unity");
         //   var sceneGuid = new Hash128("52b77c03e0aae864286b8f57b3216c18");
            var sceneEntity = SceneSystem.LoadSceneAsync(customWorldUnmanaged, sceneGuid);

            while (SceneSystem.IsSceneLoaded(customWorldUnmanaged, sceneEntity) == false)
            {
                customWorld.Update();
                await Task.Yield();
            }```
tidal bison
#

ooh

jovial kite
#

the while loop never ends

sour ice
#

The game is still ticking frames right

#

You aren't just stuck in the loop

jovial kite
#

you can see the world update in it

tidal bison
#

you sure guid is valid?

jovial kite
#

and let's not forget: it works with the previous version

#

🙂

tidal bison
#

that's a really weird way of getting it

jovial kite
#

it's the documentation way

sour ice
#

I'm asking if the frames of the application are

jovial kite
#

it works with the previous version, I believe this should answer all the questions about the code

#

my question is: why updating the DOTS package breaks it

sour ice
#

It does not

jovial kite
#

no?

#

how so?

sour ice
#

are frames still ticking in unity

#

while you run this loop

jovial kite
#

if it wasn't ticking, would have worked with the previous version of DOTS?

sour ice
#

maybe

jovial kite
#

ok the answer is: it's ticking

tidal bison
#

or if you really want to figure that code: check whether guid , scene entity is valid

sour ice
#

the reason i ask is i remember we were having some weird issues with Task.Yield() in unity

#

and we avoided it and just do a Task.Delay(1)

#

but this was with old versions (2020)

#

can you just confirm

#

sceneEntity

#

isn't Entity.Null

#

apart from that i can't think of anything that would break here

jovial kite
#

sure, give me a minute because I am reverting the code to see if I spot any difference

#

for some reason after the update Transform (V1) is not valid anymore

#

so I changed more code than I like

sour ice
#

yeah it was only valid during pre to give people time to update

#

but yeah i'm doing the same LoadSceneAsync and IsSceneLoaded

#

though I'm not using tasks, just OnUpdate

#

and i read SceneGUID directly from SubScene

#

actually, just to confirm, your scene is in a subscene?

tidal bison
#

I believe in editor it should convert live either way

#

(haven't actually tested though)

jovial kite
#

all it does is just to hold some prefabs that I need to use as archetype

sour ice
#

(great name)

jovial kite
#

I appreciated the baking idea, but makes prototype harder imo

#

but I am all for simplify so it's ok

tidal bison
#

you could just get reference to that SubScene monob and obtain guid from it

#

(assuming loading code runs in monob)

jovial kite
#

2023 has even more problems with importing deadlocks 😦

#

I had to kill unity at least 5 times already

edgy sable
jovial kite
#

I Was trying 2023.1 which is apparently out of beta now

sour ice
#

as far as i'm aware entities doens't officially support 2023 yet

edgy sable
#

Have u getting this error when using async await?
System.StackOverflowException: The requested operation caused a stack overflow.

sour ice
#

i think you have an infinite loop 😄

jovial kite
#

ok I reverted again to the previous version, but moved away from Translation to LocalTransform and it still works

#

atm I 'll leave like this, I will be back to it another time 😛

jovial kite
#

I didn't realise that 1.0.8 was out

#

doesn't work anyway

coral marlin
#

it's not just that it's loading the entity scene for a long time? if the loop doesn't end but the scene loading does work then you should see it in the editor

jovial kite
#

it desn't get stuck because it's async but it never shows up

#

when I have time I will try the bake method

#

defo the behaviour broke after .15-pre

coral marlin
#

i suspect you were already doing something that maybe shouldnt have worked

did you try with a coroutine instead of async?

jovial kite
#

async in unity works like coroutine

#

it's all on the mainthread

coral marlin
#

i am aware but also out of other ideas based on the information available 😄

jovial kite
#

there are too many variables, like the fact that I use a custom world

#

but one constant: it worked and then it didn't 🙂

#

without changing my code

coral marlin
#

this is what we have in pre.65 and it works fine

#

i load into the default world then copy into the other one though

#

you are sure you have all the correct systems for this in your custom world?

coral marlin
#

perhaps there is a problem in the scene itself, even though it looks really simple

jovial kite
#
 world = new World("Svelto<>DOTS world");

            var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);
            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, systems);
            World.DefaultGameObjectInjectionWorld = world;
coral marlin
#

maybe useless question, did you also try to clear the entity cache ?

jovial kite
#

I know where it gets stuck because I debugged it but for the moment I moved on

#
 public static bool IsSectionLoaded(WorldUnmanaged world, Entity sectionEntity)
        {
            if (!world.EntityManager.HasComponent<SceneSectionStreamingSystem.StreamingState>(sectionEntity))
                return false;

            return (SceneSectionStreamingSystem.StreamingStatus.Loaded ==
                    world.EntityManager.GetComponentData<SceneSectionStreamingSystem.StreamingState>(sectionEntity).Status);
        }
#

Status is never Loaded

#

I will need to investigate why

tidal bison
#

did you check whether guid is valid?

#

also

#

wrap your call into try catch block

#

if your task is silently gone