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

InvalidOperationException: Target playerLoopTiming is not injected #646

Open
crisdesivo opened this issue Jan 3, 2025 · 1 comment
Open

Comments

@crisdesivo
Copy link

crisdesivo commented Jan 3, 2025

When using UniTask in Unity 2022.3.41.f1 for WebGL export I get the following error:

InvalidOperationException: Target playerLoopTiming is not injected. Please check PlayerLoopHelper.Initialize. PlayerLoopTiming:Update
  at Cysharp.Threading.Tasks.PlayerLoopHelper.ThrowInvalidLoopTiming (Cysharp.Threading.Tasks.PlayerLoopTiming playerLoopTiming) [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---

I added await UniTask.Yield(PlayerLoopTiming.Initialization); before starting the UniTask and it never proceeds.

It works without any issue for Windows/Linux export and also in the editor.

@neuecc
Copy link
Member

neuecc commented Jan 6, 2025

There are occasional reports of automatic injection not working in WebGL.
While the exact details are unclear...
As a workaround, I think it would work if you explicitly call Initialize before your product code.

var playerLoop = PlayerLoop.GetCurrentPlayerLoop();
PlayerLoopHelper.Initialize(ref playerLoop);

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

2 participants