Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with configurable Enter Play Mode settings #14

Open
lcsondes opened this issue Mar 30, 2020 · 2 comments
Open

Doesn't work with configurable Enter Play Mode settings #14

lcsondes opened this issue Mar 30, 2020 · 2 comments

Comments

@lcsondes
Copy link

The code heavily expects statics to be cleared between runs, which breaks when you use the faster Play Mode in newer versions of Unity. I have tried to fix this myself but none of my attempts worked (hence the issue instead of a PR, sorry).

I was testing with both Domain and Scene reload disabled.

Reference: https://docs.unity3d.com/Manual/ConfigurableEnterPlayMode.html

@mikehofm
Copy link

If it helps anyone, the problem seems to be in ContinuationProcessorGroup.Add():

var p = ContinuationProcessor<T>.instance;

if(p == null)
{
	p = ContinuationProcessor<T>.instance = new ContinuationProcessor<T>(InitialCapacity);
	processors.Add(ContinuationProcessor<T>.instance);
}

The static variable ContinuationProcessor<T>.instance isn't reset to null when domain reload is disabled, and therefore isn't added to the new processors list. One solution might be to add a variable to ContinuationProcessor that you could check to see if it's from a previous play session.

@muckSponge
Copy link
Owner

Thanks for investigating this. Looks like we need to hook into [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] and reset all static fields to resolve this. I'm not on the right computer to push any code but for future reference, adding something like...

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void Initialize()
{
	ContinuationProcessor<T>.instance = null;
}

..might help to resolve the issues. I'll work on it when I have access to my dev machine.

muckSponge added a commit that referenced this issue Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants