#ISystem codegen fail

1 messages · Page 1 of 1 (latest)

little swan
#

For some reason codegen fails to generate OnUpdate code for specific case

#
    [WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)]
    public partial struct ClientInitializePlayerInputSystem : ISystem
    {
        private EntityQuery _initQuery;
        private EntityQuery _toInitQuery;

        public void OnCreate(ref SystemState state)
        {
            _initQuery = SystemAPI.QueryBuilder().WithAll<PlayerInput>().WithNone<InitializedClientInput>().Build();

            _toInitQuery = SystemAPI.QueryBuilder().WithAll<PlayerInput, GhostOwnerIsLocal>().Build();
            state.RequireForUpdate(_toInitQuery);
        }

        public void OnUpdate(ref SystemState state)
        {
            if (!_initQuery.IsEmptyIgnoreFilter)
            {
                return;
            }

            var count = _toInitQuery.CalculateEntityCount();
            if (count != 1)
            {
                Debug.LogError("More than one locally owned input initialized.");
            }

            Debug.Log("InitializedInput");

            state.EntityManager.AddComponent<InitializedClientInput>(_initQuery);
        }
    }
#

Here full code of system

#

So it seems like OnUpdate is not generated at all

#

and debugging session confirm that

#

During debugging it feels like code is just going from start to end, without ever triggering any debug log

last stream
#

You sure system is running?

little swan
#

and no logs appear at all, even though system runs past initial early out for sure

little swan
last stream
#

You don't have any code gen inside on update

little swan
#

for early out - every frame

#

after early out - only once

last stream
#

So I don't really get what needs to generate?

little swan
#

(which it should)

little swan
#

let me show

last stream
#

Never mind somehow missed the query create

little swan
#

here how breakpoint triggers

#

and here what happens as soon as I press Step Over (only once)

last stream
#

Why do you have require for update and IsEmptyIgnoreFilter (offtopic just a note)

little swan
#

different queries

last stream
#

Why not both require for update, anyway not the problem

little swan
#

it's !IsEmtpy

last stream
#

Oh my bad ok

#

Yeah I don't know what's going on here

little swan
#

@outer patio might be worth taking a look

last stream
#

as far as i can tell the code is running?

#

and all you're saying is Debug.Log isn't executing

little swan
#

also

#

no component is added

last stream
#

there should be no code gen because you have no code gen

#

its not burst compiled

#

so it's just mono

little swan
#

yeah, that's what makes it even more weird

last stream
#

i'd suggest just closing unity, clearing scriptassemblies

#

and reloading

little swan
#

I also nuked library

last stream
#

oh?

little swan
#

yep

last stream
#

seems unlikely something so simple is broken 🤔 but if you've nuked library i got no idea

#

code gen looks fine

#

just curiously, what happens if you burst compile it

#

wait can you check something, go to the directory of hte .cs file

#

there is no cloned ~ version of the file is there?

little swan
#

this has been bothering me too a lot lately, so that was first thing I checked

last stream
#

oh you suffering as well? 😦

little swan
#

it was burst compiled initially and it didn't work. now I'll check again

last stream
#

like a virus, slowly spreading

little swan
#

Bursting OnUpdate made no difference

outer patio
#

this is very weird. I'll see if this happens in an empty project, but if not I'll probably need a repro

outer patio
#

well hold on, you probably wanna debug log before the early out right

#

because if it debug logs there the thing is running and the isemptyignorefilter is true

#

that codegen is not the only codegen that happens for isystem, btw

#

that's the sourcegenerator stuff, which is for systemapi and ije and what have you, but there's also the ilpp stuff, which generates the bursted static entry point for onupdate etc

#

that stuff you can only see by opening the assembly in ilspy

little swan
outer patio
#

i'm saying just print before

#

to see if the onupdate is running

#

because if that print prints, the onupdate is running fine, and something else is funky

little swan
#

OnUpdate is running, yes. It's visible from both: System profiler and debugging early out code also works perfectly fine

outer patio
#

sooo what makes you think it's a codegen problem? i'm not sure i see anything in that onupdate that needs codegen

little swan
#

It was my first thought. Rn I have no idea what is failing 😅

#

I rewrote it like this and now it works fine

            if (SystemAPI.HasSingleton<InitializedClientInput>())
            {
                return;
            }

            var ecb = new EntityCommandBuffer(state.WorldUpdateAllocator);
            var count = 0;

            foreach (var (input, e) in SystemAPI.Query<PlayerInput>().WithAll<GhostOwnerIsLocal>().WithEntityAccess())
            {
                ecb.AddComponent<InitializedClientInput>(e);
                Debug.Log("InitializedInput");
                count++;
            }

            if (count != 1)
            {
                Debug.LogError("More than one locally owned input initialized.");
            }

            ecb.Playback(state.EntityManager);
outer patio
#

ah. well so if there's no systemapi etc for sourcegenerators to do, i think it probably just doesn't generate anything for onupdate

little swan
#

but something is funny about original code. It should be valid