In my project I am trying to build a dedicated server build to deploy to Multiplay hosting services.
Build target is Linux OS,build settings are default, scripting backend set to IL2CPP.
When Addressables.InstantiateAsync()
is being called for the first time, or when Resources.Load()
gets called, a "Graphics device is null" error is fired and the server crashes. Here are the logs:
When using Addressables.InstantiateAsync().WaitForCompletion()
:
Graphics device is null.
UnityEngine.ResourceManagement.ResourceProviders.AssetBundleResource:GetAssetBundle()
UnityEngine.ResourceManagement.ResourceProviders.AssetBundleResource:WaitForCompletionHandler()
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:WaitForCompletion()
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle:WaitForCompletion()
UnityEngine.ResourceManagement.AsyncOperations.GroupOperation:InvokeWaitForCompletion()
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:WaitForCompletion()
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1:WaitForCompletion()
UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1:InvokeWaitForCompletion()
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:WaitForCompletion()
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1:WaitForCompletion()
UnityEngine.ResourceManagement.InstanceOperation:InvokeWaitForCompletion()
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:WaitForCompletion()
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1:WaitForCompletion()
<OnAllocate>d__5:MoveNext()
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Runtime.CompilerServices.MoveNextRunner:Run()
System.Threading.Tasks.AwaitTaskContinuation:RunOrScheduleAction(Action, Boolean, Task&)
System.Threading.Tasks.Task:FinishContinuations()
System.Threading.Tasks.Task`1:TrySetResult(TResult)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult(TResult)
Unity.Services.Multiplay.Internal.<GetPayloadAllocationAsPlainText>d__9:MoveNext()
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Runtime.CompilerServices.MoveNextRunner:Run()
System.Threading.Tasks.AwaitTaskContinuation:RunOrScheduleAction(Action, Boolean, Task&)
System.Threading.Tasks.Task:FinishContinuations()
System.Threading.Tasks.Task`1:TrySetResult(TResult)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult(TResult)
Unity.Services.Multiplay.Apis.Payload.<PayloadAllocationAsync>d__7:MoveNext()
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Runtime.CompilerServices.MoveNextRunner:Run()
System.Threading.Tasks.AwaitTaskContinuation:RunOrScheduleAction(Action, Boolean, Task&)
System.Threading.Tasks.Task:FinishContinuations()
System.Threading.Tasks.Task`1:TrySetResult(TResult)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult(TResult)
Unity.Services.Multiplay.Http.<MakeRequestAsync>d__1:MoveNext()
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Runtime.CompilerServices.MoveNextRunner:Run()
System.Threading.Tasks.AwaitTaskContinuation:RunOrScheduleAction(Action, Boolean, Task&)
System.Threading.Tasks.Task:FinishContinuations()
System.Threading.Tasks.Task`1:TrySetResult(TResult)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult(TResult)
Unity.Services.Multiplay.Http.<CreateWebRequestAsync>d__3:MoveNext()
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Runtime.CompilerServices.MoveNextRunner:Run()
System.Threading.ThreadPoolWorkQueue:Dispatch()
[ line 729763672]
Then I was able to solve this by replacing the WaitForCompletion()
with awaiting the Task (await taskName.Task
), but encounter this error when starting up a session in Photon Fusion:
Graphics device is null.
UnityEngine.Resources:Load(String)
Fusion.<>c:<Reload>b__6_0()
System.Lazy`1:ViaFactory(LazyThreadSafetyMode)
System.Lazy`1:CreateValue()
Fusion.NetworkProjectConfig:get_Global()
Fusion.NetworkRunner:StartGame(StartGameArgs)
ServerLauncher:StartSimulation(NetworkRunner, Int32, String, String, String, String, Dictionary`2, Int32)
<OnAllocate>d__5:MoveNext()
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Runtime.CompilerServices.MoveNextRunner:Run()
System.Threading.ThreadPoolWorkQueue:Dispatch()
The server runs in a batchMode, meaning the Launch Parameters are -nographics -batchmode
.
It sounds like a very standard scenario, but I couldn't find any solution anywhere, including approaching the Multiplay support team.
Can someone shed some light on this?