UniTask
UniTask copied to clipboard
InvalidOperationException: Target playerLoopTiming is not injected
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.
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);
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.