Skip to content

Diagnostics collection fails due to null ref #858

Description

@Geminior

The following exception randomly started to occur. Not consistently but most of the time:

NullReferenceException: Object reference not set to an instance of an object
VContainer.Diagnostics.DiagnositcsContext+<>c__DisplayClass8_0.<FindByRegistration>b__0 (VContainer.Diagnostics.DiagnosticsInfo x) (at ./Library/PackageCache/jp.hadashikick.vcontainer@e76362137fea/Runtime/Diagnostics/DiagnosticsContext.cs:53)
System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate, System.Boolean& found) (at <80564d689e48448fa2a7101993ee7201>:0)
System.Linq.Enumerable.FirstOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) (at <80564d689e48448fa2a7101993ee7201>:0)
VContainer.Diagnostics.DiagnositcsContext.FindByRegistration (VContainer.Registration registration) (at ./Library/PackageCache/jp.hadashikick.vcontainer@e76362137fea/Runtime/Diagnostics/DiagnosticsContext.cs:53)
VContainer.Diagnostics.DiagnosticsCollector.TraceResolve (VContainer.Registration registration, System.Func`2[T,TResult] resolving) (at ./Library/PackageCache/jp.hadashikick.vcontainer@e76362137fea/Runtime/Diagnostics/DiagnosticsCollector.cs:60)
VContainer.ScopedContainer.Resolve (VContainer.Registration registration) (at ./Library/PackageCache/jp.hadashikick.vcontainer@e76362137fea/Runtime/Container.cs:113)
VContainer.ScopedContainer.Resolve (System.Type type, System.Object key) (at ./Library/PackageCache/jp.hadashikick.vcontainer@e76362137fea/Runtime/Container.cs:91)
VContainer.IObjectResolverExtensions.Resolve[T] (VContainer.IObjectResolver resolver, System.Object key) (at ./Library/PackageCache/jp.hadashikick.vcontainer@e76362137fea/Runtime/IObjectResolverExtensions.cs:10)
Balrog.Installers.MatchLifetimeScopeBase.RegisterMatchConfigurationOverrides (VContainer.IContainerBuilder builder) (at Assets/Scripts/Game/Installers/MatchLifetimeScopeBase.cs:147)
Balrog.Installers.MatchLifetimeScopeBase.Configure (VContainer.IContainerBuilder builder) (at Assets/Scripts/Game/Installers/MatchLifetimeScopeBase.cs:136)
VContainer.Unity.LifetimeScope.InstallTo (VContainer.IContainerBuilder builder) (at ./Library/PackageCache/jp.hadashikick.vcontainer@e76362137fea/Runtime/Unity/LifetimeScope.cs:286)
VContainer.Unity.LifetimeScope.<Build>b__43_0 (VContainer.IContainerBuilder builder) (at ./Library/PackageCache/jp.hadashikick.vcontainer@e76362137fea/Runtime/Unity/LifetimeScope.cs:204)
VContainer.ScopedContainer.CreateScope (System.Action`1[T] installation) (at ./Library/PackageCache/jp.hadashikick.vcontainer@e76362137fea/Runtime/Container.cs:125)
VContainer.Unity.LifetimeScope.Build () (at ./Library/PackageCache/jp.hadashikick.vcontainer@e76362137fea/Runtime/Unity/LifetimeScope.cs:199)
Balrog.Installers.MatchLifetimeScopeBase.StartAsync (System.Threading.CancellationToken cancellationToken) (at Assets/Scripts/Game/Installers/MatchLifetimeScopeBase.cs:74)
UnityEngine.Debug:LogException(Exception)
Cysharp.Threading.Tasks.UniTaskScheduler:PublishUnobservedTaskException(Exception) (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/UniTaskScheduler.cs:90)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder:SetException(Exception) (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs:53)
Balrog.Installers.<StartAsync>d__3:MoveNext() (at Assets/Scripts/Game/Installers/MatchLifetimeScopeBase.cs:83)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid`1:Run() (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/CompilerServices/StateMachineRunner.cs:104)
Cysharp.Threading.Tasks.AwaiterActions:Continuation(Object) (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/UniTask.cs:25)
Cysharp.Threading.Tasks.UniTaskCompletionSourceCore`1:TrySetResult(AsyncUnit) (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/UniTaskCompletionSource.cs:139)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`1:SetResult() (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/CompilerServices/StateMachineRunner.cs:204)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskMethodBuilder:SetResult() (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/CompilerServices/AsyncUniTaskMethodBuilder.cs:70)
Balrog.Installers.<WaitForScenesAndSubScenesToLoadAsync>d__2:MoveNext() (at Assets/Scripts/Game/Installers/EcsInstallerUtil.cs:127)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`1:Run() (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/CompilerServices/StateMachineRunner.cs:189)
Cysharp.Threading.Tasks.AwaiterActions:Continuation(Object) (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/UniTask.cs:25)
Cysharp.Threading.Tasks.UniTaskCompletionSourceCore`1:TrySetResult(AsyncUnit) (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/UniTaskCompletionSource.cs:139)
Cysharp.Threading.Tasks.WhenAllPromise:TryInvokeContinuation(WhenAllPromise, Awaiter&) (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/UniTask.WhenAll.cs:210)
Cysharp.Threading.Tasks.<>c:<.ctor>b__3_0(Object) (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/UniTask.WhenAll.cs:189)
Cysharp.Threading.Tasks.UniTaskCompletionSourceCore`1:TrySetResult(AsyncUnit) (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/UniTaskCompletionSource.cs:139)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`1:SetResult() (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/CompilerServices/StateMachineRunner.cs:204)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskMethodBuilder:SetResult() (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/CompilerServices/AsyncUniTaskMethodBuilder.cs:70)
Balrog.Installers.<WaitForSubScenesLoadedAsync>d__5:MoveNext() (at Assets/Scripts/Game/Installers/EcsInstallerUtil.cs:175)
Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`1:Run() (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/CompilerServices/StateMachineRunner.cs:189)
Cysharp.Threading.Tasks.AwaiterActions:Continuation(Object) (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/UniTask.cs:25)
Cysharp.Threading.Tasks.UniTaskCompletionSourceCore`1:TrySetResult(Object) (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/UniTaskCompletionSource.cs:139)
Cysharp.Threading.Tasks.DelayPromise:MoveNext() (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/UniTask.Delay.cs:810)
Cysharp.Threading.Tasks.Internal.PlayerLoopRunner:RunCore() (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/Internal/PlayerLoopRunner.cs:203)
Cysharp.Threading.Tasks.Internal.PlayerLoopRunner:Update() (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/Internal/PlayerLoopRunner.cs:145)
Cysharp.Threading.Tasks.Internal.PlayerLoopRunner:Run() (at ./Library/PackageCache/com.cysharp.unitask@a85b92a8e443/Runtime/Internal/PlayerLoopRunner.cs:104)

The issue is with this section of code in DiagnositcsContext (which also has a typo)

        internal static DiagnosticsInfo FindByRegistration(Registration registration)
        {
            return GetDiagnosticsInfos().FirstOrDefault(x => x.ResolveInfo.Registration == registration);
        }

ResolveInfo is null for one or more DiagnosticInfos returned by GetDiagnosticsInfos.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions