Comments (6)
Having the same issue. Did you manage to fix it?
from addressables-sample.
We're also seeing this issue, using Addressables 1.20.5
Callstack is as follows
System.Exception: Attempting to use an invalid operation handle File "AsyncOperationHandle.cs", line 213, in get_InternalOp File "AsyncOperationHandle.cs", line 278, in get_Result File "InitializationOperation.cs", line 95, in Execute File "AsyncOperationBase.cs", line 536, in InvokeExecute File "AsyncOperationBase.cs", line 148, in <.ctor>b__35_0 File "AsyncOperationBase.cs", line 330, in add_CompletedTypeless { <lambda> } File "Generics12.cpp", line 20941, in Invoke File "Generics47.cpp", in Invoke File "AsyncOperationBase.cs", line 395, in InvokeCompletionEvent File "AsyncOperationBase.cs", line 508, in Complete File "Generics23.cpp", line 25763, in Complete File "AsyncOperationBase.cs", line 435, in Complete File "Unity.Addressables.cpp", line 9095, in Execute { <lambda> } File "Generics12.cpp", line 21097, in Invoke File "Generics47.cpp", in Invoke File "AsyncOperationBase.cs", line 395, in InvokeCompletionEvent File "AsyncOperationBase.cs", line 508, in Complete File "Unity.ResourceManager.cpp", line 35049, in CompleteIfDependenciesComplete File "GroupOperation.cs", line 228, in OnOperationCompleted File "AsyncOperationBase.cs", line 330, in add_CompletedTypeless { <lambda> } File "Generics12.cpp", line 20941, in Invoke File "Generics47.cpp", in Invoke File "AsyncOperationBase.cs", line 395, in InvokeCompletionEvent File "AsyncOperationBase.cs", line 508, in Complete File "Generics23.cpp", line 25763, in Complete File "AsyncOperationBase.cs", line 435, in Complete File "PlayAssetDeliveryInitialization.cs", line 76, in CompleteOverride File "AddressablesPlayAssetDelivery.cpp", line 4686, in DownloadCustomAssetPacksData { <lambda> }
from addressables-sample.
@kirstenpilla hi, do you have any idea what might cause this issue?
We're using the code from the Play Asset Delivery sample project you added, and using Unity 2020.3.13f1 with addressables 1.20.5.
The error occurs at launch every session after the PlayAssetDeliveryInitializeOperation
completes. Some callback assigned to the CompletedTypeless event throws an exception, but I've struggled to find out which class/method it is. Regardless I believe it's complaining that the PlayAssetDeliveryInitializeOperation
itself is invalid.
If you have any information or ideas to try, please advise, thank you!
from addressables-sample.
@JPerryOddGames Hello, have you solved the issue yet?
I also have same problem but using Unity 2021.3.16 with latest addresssables. I believe the problem was ProvideHandle m_ProviderInterface in PlayAssetDeliveryAssetBundleProvider replaced by dependencies.
When Addressables.LoadAssetAsync(resourceAddress), it will fetch the target resource and its all dependencies. Then the target resources is part of the asset pack and try to download it if not installed. Because the download method in PAD sample is void not async, it make execute the others dependencies where I believe generate new ProvideHandle then overwrite ProvideHandle m_ProviderInterface. So when the PAD download completed, the callback invoke other m_ProviderInterface.
from addressables-sample.
@JPerryOddGames After I make async, the dependencies will wait for download to be completed. So there is no invalid handle any more because overwritten the m_ProviderInterface. Here is my modified codes. Notice I move m_ProviderInterface = providerInterface;
from Provide method to LoadFromAssetPack method and add while loop before it.
from addressables-sample.
Apologies @restush , I never received a notification from your replies in this thread. We did manage to solve the issue on the 1st of Feb and have not seen it since (in 10 weeks) so I assume it's entirely fixed.
I'll include my fix below. Note that m_ProviderInterface
no longer exists in class-scope at all; Instead, the object is passed directly to the methods that require it.
Code
using System;
using System.ComponentModel;
using System.IO;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Android;
using UnityEngine.ResourceManagement.ResourceProviders;
namespace AddressablesPlayAssetDelivery
{
/// <summary>
/// Ensures that the asset pack containing the AssetBundle is installed/downloaded before attemping to load the bundle.
/// </summary>
[DisplayName("Play Asset Delivery Provider")]
public class PlayAssetDeliveryAssetBundleProvider : AssetBundleProvider
{
public override void Provide(ProvideHandle providerInterface)
{
#if UNITY_ANDROID && !UNITY_EDITOR
LoadFromAssetPack(providerInterface);
#else
base.Provide(providerInterface);
#endif
}
#if UNITY_ANDROID
private void LoadFromAssetPack(ProvideHandle providerInterface)
{
string bundleName = Path.GetFileNameWithoutExtension(providerInterface.Location.InternalId);
if (!PlayAssetDeliveryRuntimeData.Instance.BundleNameToAssetPack.ContainsKey(bundleName))
{
// Bundle is either assigned to the generated asset packs, or not assigned to any asset pack
base.Provide(providerInterface);
}
else
{
// Bundle is assigned to a custom fast-follow or on-demand asset pack
string assetPackName = PlayAssetDeliveryRuntimeData.Instance.BundleNameToAssetPack[bundleName].AssetPackName;
if (PlayAssetDeliveryRuntimeData.Instance.AssetPackNameToDownloadPath.ContainsKey(assetPackName))
{
// Asset pack is already downloaded
base.Provide(providerInterface);
}
else
{
// Download the asset pack
DownloadRemoteAssetPack(assetPackName, providerInterface);
}
}
}
private async void DownloadRemoteAssetPack(string assetPackName, ProvideHandle providerInterface)
{
// Note that most methods in the AndroidAssetPacks class are either direct wrappers of java APIs in Google's PlayCore plugin,
// or depend on values that the PlayCore API returns. If the PlayCore plugin is missing, calling these methods will throw an InvalidOperationException exception.
try
{
await ProcessRequest(Google.Play.AssetDelivery.PlayAssetDelivery.RetrieveAssetPackAsync(assetPackName), assetPackName, providerInterface);
}
catch (InvalidOperationException ioe)
{
Debug.LogError($"Cannot retrieve state for asset pack '{assetPackName}'. PlayCore Plugin is not installed: {ioe.Message}");
providerInterface.Complete(this, false, new Exception("exception"));
}
}
private async Task ProcessRequest(Google.Play.AssetDelivery.PlayAssetPackRequest request, string assetPackName, ProvideHandle providerInterface)
{
while (!request.IsDone)
await System.Threading.Tasks.Task.Yield();
Debug.Log($"[PlatAssetDeliveryBundleProvider] {assetPackName} finished downloading, now waiting for installation");
while (request.Error != Google.Play.AssetDelivery.AssetDeliveryErrorCode.NoError && (request.Status != Google.Play.AssetDelivery.AssetDeliveryStatus.Available || request.Status != Google.Play.AssetDelivery.AssetDeliveryStatus.Loaded))
await System.Threading.Tasks.Task.Yield();
Debug.Log($"[PlatAssetDeliveryBundleProvider] {assetPackName} finished waiting status: {request.Status}, error: {request.Error}");
string message = string.Empty;
if (request.Error != Google.Play.AssetDelivery.AssetDeliveryErrorCode.NoError)
message = $"Failed to retrieve the state of asset pack '{assetPackName}'.";
else
{
string assetPackPath = AndroidAssetPacks.GetAssetPackPath(assetPackName);
if (!string.IsNullOrEmpty(assetPackPath))
{
// Asset pack was located on device. Proceed with loading the bundle.
PlayAssetDeliveryRuntimeData.Instance.AssetPackNameToDownloadPath[assetPackName] = assetPackPath;
base.Provide(providerInterface);
}
else
message = $"Downloaded asset pack '{assetPackName}' but cannot locate it on device.";
}
if (!string.IsNullOrEmpty(message))
{
Debug.LogError(message);
providerInterface.Complete(this, false, new Exception("exception"));
}
}
#endif
}
}
from addressables-sample.
Related Issues (20)
- SpaceShooter DynamicInvoke error while playing
- Error - JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll HOT 1
- How do I get the scene name?
- The BuildProcessorData.json and CustomAssetPacksData.json not generated
- Are google play instant apps possible to be downloaded using the Play Asset Delivery example?
- WaitForCompletion() not working? HOT 1
- Removing a Specific Child Object in a Content Update Causes an Error. HOT 1
- Play Asset Delivery sample silently fails if bundle names conflict HOT 1
- Play Asset Delivery sample does not properly load from fast-follow Asset Pack HOT 1
- Addressables are not working on WebGL on new Unity versions HOT 1
- Request to PGS failed because all packs are unavailable HOT 1
- Custom asset packs are not generated HOT 1
- PAD sample does not build HOT 4
- error display before enter the game
- Error constantly reported when selecting assets configuration and cannot be modified HOT 1
- Addressables + PAD not working with google.play.core 1.8.1, google.play.assetdelivery 1.8.1 (api 2.0.0, Unity 2022) HOT 1
- Download On-demand assets gets failure at random HOT 1
- Address 'xxx' cannot contain '[]' error HOT 2
- Does Addressables support 8K videos?
- In IDE, I can use editorAsset through AssetReference, and there are no errors when loading scripts in IDE or Unity. However, during build, Unity prompts me that AssetReference does not include the definition of editorAsset
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from addressables-sample.