Hey,
I receive the following exception from Addressables when using the InstantiateAsync method of an AssetReference:
System.Exception: Cannot increment reference count on operation UnityEngine.ResourceManagement.ResourceManager+InstanceOperation, result=ââ, status=âNoneâ because it has already been destroyed at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].IncrementReferenceCount () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1[TObject].Start (UnityEngine.ResourceManagement.ResourceManager rm, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency, DelegateList1[T] updateCallbacks) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.ResourceManager.StartOperation[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1[TObject] operation, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.ResourceManager.ProvideInstance (UnityEngine.ResourceManagement.ResourceProviders.IInstanceProvider provider, UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location, UnityEngine.ResourceManagement.ResourceProviders.InstantiationParameters instantiateParameters) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.AddressableAssets.AddressablesImpl.InstantiateAsync (UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location, UnityEngine.ResourceManagement.ResourceProviders.InstantiationParameters instantiateParameters, System.Boolean trackHandle) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.AddressableAssets.AddressablesImpl.InstantiateAsync (System.Object key, UnityEngine.ResourceManagement.ResourceProviders.InstantiationParameters instantiateParameters, System.Boolean trackHandle) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.AddressableAssets.Addressables.InstantiateAsync (System.Object key, UnityEngine.Transform parent, System.Boolean instantiateInWorldSpace, System.Boolean trackHandle)
I load skins of characters in the menu scene. When a match is started, all skins are unloaded as well as the scene. The loading scene than loads the skins for the match in a coroutine. Randomly the exception is thrown while loading.
Is this a known bug?
Thanks for your help!
Hey @SviperSniper , this isnât a known issue as far as Iâm aware. My first instinct is to think it may be an issue with the cached async operations. Would it be possible for you to provide a little more information? Specifically how are you loading skins on your main menu scene and how are you loading them again when a match starts?
If you have a small project that reproduces the issue consistently that would also be a massive help.
Edit: I should mention, if you have a project you donât mind sharing but donât want to post it on the forums youâre welcome to file a bug with Unity and post the case number in this thread so I can look it up.
Hi David,
thanks for your reply.
We will try to provide a small project as soon as we can but it is probably not that easy to reproduce since it is not happening 100% of the time.
We are actually seeing quite a few different kinds of exceptions in our crash reporting tool which all seem to be related to the same issue:
java.lang.Exception: Object reference not set to an instance of an object. : System.NullReferenceException: Object reference not set to an instance of an object.
at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].DecrementReferenceCount () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1[TObject].Complete (TObject result, System.Boolean success, System.String errorMsg) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.ResourceManager+InstanceOperation.Execute () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].InvokeExecute () [0x00000] in <00000000000000000000000000000000>:0 at System.Action
1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
at DelegateList1[T].Invoke (T res) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1[TObject].InvokeCompletionEvent () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].Complete (TObject result, System.Boolean success, System.String errorMsg) [0x00000] in <00000000000000000000000000000000>:0 at System.Action
1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.AsyncOperation.InvokeCompletionEvent () [0x00000] in <00000000000000000000000000000000>:0
java.lang.Exception: MonoBehaviourCallbackHooks ResourceManagerCallbacks: Exception : System.Exception: Cannot decrement reference count for operation UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation1[UnityEngine.ResourceManagement.ResourceProviders.IAssetBundleResource], result='', status='None' because it is already 0 at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1[TObject].DecrementReferenceCount () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.ResourceManager.ExecuteDeferredCallbacks () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.ResourceManager.Update (System.Single unscaledDeltaTime) [0x00000] in <00000000000000000000000000000000>:0
at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
java.lang.Exception: MonoBehaviourCallbackHooks ResourceManagerCallbacks: Exception : System.Exception: Cannot decrement reference count for operation UnityEngine.ResourceManagement.ResourceManager+InstanceOperation, result=ââ, status=âNoneâ because it is already 0
at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].DecrementReferenceCount () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.ResourceManager.ExecuteDeferredCallbacks () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.ResourceManager.Update (System.Single unscaledDeltaTime) [0x00000] in <00000000000000000000000000000000>:0 at System.Action
1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
java.lang.Exception: Cannot decrement reference count for operation UnityEngine.ResourceManagement.ResourceManager+InstanceOperation, result=ââ, status=âNoneâ because it is already 0 : System.Exception: Cannot decrement reference count for operation UnityEngine.ResourceManagement.ResourceManager+InstanceOperation, result=ââ, status=âNoneâ because it is already 0
at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].DecrementReferenceCount () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.ResourceManager.CleanupSceneInstances (UnityEngine.SceneManagement.Scene scene) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.AddressableAssets.AddressablesImpl.OnSceneUnloaded (UnityEngine.SceneManagement.Scene scene) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.UnityAction
1[T0].Invoke (T0 arg0) [0x00000] in <00000000000000000000000000000000>:0
java.lang.Exception: Loader MatchLoader: Exception : System.Exception: Cannot increment reference count on operation UnityEngine.ResourceManagement.ResourceManager+InstanceOperation, result=ââ, status=âNoneâ because it has already been destroyed
at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].IncrementReferenceCount () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1[TObject].Start (UnityEngine.ResourceManagement.ResourceManager rm, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency, DelegateList1[T] updateCallbacks) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.ResourceManager.StartOperation[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1[TObject] operation, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.ResourceManager.ProvideInstance (UnityEngine.ResourceManagement.ResourceProviders.IInstanceProvider provider, UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location, UnityEngine.ResourceManagement.ResourceProviders.InstantiationParameters instantiateParameters) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.AddressableAssets.AddressablesImpl.InstantiateAsync (UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location, UnityEngine.ResourceManagement.ResourceProviders.InstantiationParameters instantiateParameters, System.Boolean trackHandle) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.AddressableAssets.AddressablesImpl.InstantiateAsync (System.Object key, UnityEngine.ResourceManagement.ResourceProviders.InstantiationParameters instantiateParameters, System.Boolean trackHandle) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.AddressableAssets.Addressables.InstantiateAsync (System.Object key, UnityEngine.Transform parent, System.Boolean instantiateInWorldSpace, System.Boolean trackHandle) [0x00000] in <00000000000000000000000000000000>:0
at Assets._SuperSpellSaga.Scripts.Features.MatchSystem.Loading.LoadingSteps.ArenaLoadingStep+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0
java.lang.Exception: Attempting to use an invalid operation handle : System.Exception: Attempting to use an invalid operation handle
at MonoBehaviourCallbackHooksâŚctor () [0x00000] in <00000000000000000000000000000000>:0
at MonoBehaviourCallbackHooksâŚctor () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.AsyncOperations.GroupOperation.CompleteIfDependenciesComplete () [0x00000] in <00000000000000000000000000000000>:0
at System.Action1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0 at DelegateList
1[T].Invoke (T res) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].InvokeCompletionEvent () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1[TObject].Complete (TObject result, System.Boolean success, System.String errorMsg) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation1[TObject].ProviderCompleted[T] (T result, System.Boolean status, System.Exception e) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation
1[TObject].ProviderCompleted[T] (T result, System.Boolean status, System.Exception e) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.ResourceProviders.AssetBundleResource.WebRequestOperationCompleted (UnityEngine.AsyncOperation op) [0x00000] in <00000000000000000000000000000000>:0
at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.AsyncOperation.InvokeCompletionEvent () [0x00000] in <00000000000000000000000000000000>:0
java.lang.Exception: Attempting to use an invalid operation handle : System.Exception: Attempting to use an invalid operation handle
at MonoBehaviourCallbackHooksâŚctor () [0x00000] in <00000000000000000000000000000000>:0
at MonoBehaviourCallbackHooksâŚctor () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.AsyncOperations.GroupOperation.CompleteIfDependenciesComplete () [0x00000] in <00000000000000000000000000000000>:0
at System.Action1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0 at DelegateList
1[T].Invoke (T res) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].InvokeCompletionEvent () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1[TObject].Complete (TObject result, System.Boolean success, System.String errorMsg) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ResourceManagement.ResourceProviders.AssetBundleResource.WebRequestOperationCompleted (UnityEngine.AsyncOperation op) [0x00000] in <00000000000000000000000000000000>:0
at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.AsyncOperation.InvokeCompletionEvent () [0x00000] in <00000000000000000000000000000000>:0
Any help would be greatly appreciated!
Best regards
So, the âAttempting to use an invalid operation handleâ is an error Iâve seen recently. It had to do with a race condition we were encountering on WebGL after bundles had been downloaded and cached and a user attempted to reload them.
I should have asked before, what platform are you seeing these on? Also what version of the package are you using?
We receive this exceptions on Android and iOS.
The Unity version is 2019.2.9f1 and the Addressables Version is 1.2.4.
We only have local asset bundles
I see, so the issue wasnât so much âcachedâ bundles as it was WebRequestOperations finishing immediately and Addressables is attempting to use the op handle to set a progress callback afterwards. Since your bundles are local it could still be hitting the same condition.
If that is the case it should be fixed in a coming release. You can either check the release when in comes out in the next week or two and report back if youâre still having the problem or you can change some lines in the Resource Providers
In AssetBundleProvider.cs and BundledAssetProvider.cs youâll see in Start(ProvideHandle provideHandle) there should be a line towards the bottom that should look like either provideHandle.SetProgressCallback(ProgressCallback); or provideHandle.SetProgressCallback(PercentComplete); Try moving these up. For AssetBundleProvider move the line just above the BeginOperation() call. For BundledAssetProvider just move that line to be the first line of the Start method.
If youâre using Virtual mode, the LegacyResourceProvider, or the TextDataProvider for anything you may need to do something similar in VirtualAssetBundleProvider, LegacyResoucesProvider, or TextDataProvider respectively.
If none of that helps just submit a bug with Unity (providing a repro project if you can) and post the case number in this thread so we can see whatâs going on.
These are awesome news!
We will wait for the update and will inform you / create a bug ticket if the issue persists.
Thanks a lot for your help!
I have another question regarding this ticket:
We have the same issue on Android devices.
There is no CRC exception but it also throws an Exception with
âRemoteAssetBundleProvider unable to load from url jarâ
with either âRequest abortedâ or âReceived no data in responseâ as the result.
We use verison 1.2.4 and local bundles in StreamingAssets.
It appears randomly on different devices and its unfortunately not reproducible.
Are there any news about how to solve this?
Thanks for your help!
Do you have any idea how to approach this?
Best regards
Hmm⌠Iâm not familiar with that issue. Since it isnât consistently reproducible that makes it tricky to track down. If youâre ever able to get a consistent project that reproduces the issue please send it our way so we can help.
Iâll definitely keep an eye out for this issue on our end and see what can be done. Have you already filed a bug with Unity about this? Thatâll be a lot of help to us in keeping up with the status of this issue.
There is no bug ticket yet. I will try to collect more information and will create a ticket if the issue persists.
Thanks again for your help, David!
1 Like
Hi!
I have a very similar bug. Here is a small test project. Unity 2019.3.0f3, Addressables 1.6.0. Simply setup a localhost to reach the addressables (I used python -m http.server but that shouldnât be a problem) and start the project in Unity Editor. I tried with setting the Editor to Windows platform and using the âUse existing buildâ Playmode script for the addressables. After 10-15 clicks randomly on the buttons the error appeared and all the clicks gave the same error after that.
Here is the zip of the project (Unity 2019.3.0f3):
And the error:
Exception: Cannot increment reference count on operation UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[UnityEngine.ResourceManagement.ResourceProviders.IAssetBundleResource], result='', status='Succeeded' because it has already been destroyed
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].IncrementReferenceCount () (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:130)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].Start (UnityEngine.ResourceManagement.ResourceManager rm, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency, DelegateList`1[T] updateCallbacks) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:398)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].UnityEngine.ResourceManagement.AsyncOperations.IAsyncOperation.Start (UnityEngine.ResourceManagement.ResourceManager rm, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency, DelegateList`1[T] updateCallbacks) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:471)
UnityEngine.ResourceManagement.ResourceManager.StartOperation (UnityEngine.ResourceManagement.AsyncOperations.IAsyncOperation operation, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/ResourceManager.cs:413)
UnityEngine.ResourceManagement.ResourceManager.ProvideResource (UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location, System.Type desiredType) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/ResourceManager.cs:376)
UnityEngine.ResourceManagement.ResourceManager.ProvideResourceGroupCached (System.Collections.Generic.IList`1[T] locations, System.Int32 groupHash, System.Type desiredType, System.Action`1[T] callback) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/ResourceManager.cs:564)
UnityEngine.ResourceManagement.ResourceManager.ProvideResource (UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location, System.Type desiredType) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/ResourceManager.cs:370)
UnityEngine.ResourceManagement.ResourceManager.ProvideResource[TObject] (UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/ResourceManager.cs:393)
UnityEngine.AddressableAssets.AddressablesImpl.LoadAssetAsync[TObject] (System.Object key) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/AddressablesImpl.cs:455)
UnityEngine.AddressableAssets.Addressables.LoadAssetAsync[TObject] (System.Object key) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/Addressables.cs:304)
LoadOperation.Load (UnityEngine.AddressableAssets.AssetReference addressableAssetPrefab, System.Action`1[T] DoAfterLoadCompleted) (at Assets/Scripts/AddressablePrefabLoader.cs:80)
AddressablePrefabLoader.Instantiate (UnityEngine.AddressableAssets.AssetReference addressableAssetPrefab, UnityEngine.Transform parent) (at Assets/Scripts/AddressablePrefabLoader.cs:31)
LoaderTest.Load (System.Int32 idx) (at Assets/Scripts/LoaderTest.cs:14)
UnityEngine.Events.InvokableCall`1[T1].Invoke (T1 args0) (at <7d22f8e71133418c87c7b26ea181f3e3>:0)
UnityEngine.Events.CachedInvokableCall`1[T].Invoke (System.Object[] args) (at <7d22f8e71133418c87c7b26ea181f3e3>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <7d22f8e71133418c87c7b26ea181f3e3>:0)
UnityEngine.UI.Button.Press () (at E:/gamedev/Unity_installs/2019.3.0f3/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:68)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at E:/gamedev/Unity_installs/2019.3.0f3/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:110)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at E:/gamedev/Unity_installs/2019.3.0f3/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at E:/gamedev/Unity_installs/2019.3.0f3/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update() (at E:/gamedev/Unity_installs/2019.3.0f3/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
@davidla_unity Sorry to bother you but could you please check this out? The fixes you mentioned are already in 1.6.0 but the problem exists (see my previous post with test project included). Thanks!
Hey @SXtheOne yeah weâre looking into it. Iâll make a note of your project. Thanks for posting that.
1 Like