Cannot get content from an unfinished UnityWebRequest object - unity3d

i am having this error, trying to have the app download an assetbundle from an url:
InvalidOperationException: Cannot get content from an unfinished UnityWebRequest object
UnityEngine.Networking.DownloadHandler.GetCheckedDownloader[T] (UnityEngine.Networking.UnityWebRequest www) (at <1b339e701b4b41ba9e5bacb491247150>:0)
UnityEngine.Networking.DownloadHandlerAssetBundle.GetContent (UnityEngine.Networking.UnityWebRequest www) (at <9387c707b3dc43e28471eec2e11e7579>:0)
AssetBundleAugmenter+<DownloadAndCache>d__6.MoveNext () (at Assets/AssetBundleAugmenter.cs:37)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <4746c126b0b54f3b834845974d1a9190>:0)
I followed this documentation: https://library.vuforia.com/unity-extension/package-augmentations-unity-assetbundles The image target is stored in a vuforia database, it worked well when using it with a normally built .apk with the 3D model included in the installer. The URL of the bundle is this:
https://cavetrolltest01.000webhostapp.com/AssetBundles/nickhatchery/cavetroll

Related

AssetBundle Caching Process. What happens when a Unity asset bundle is cached? What properties of an ab make it different from its cached form?

This is probably a very niche question, but what are the specific differences between an asset bundle and a cached bundle for the asset bundle system that Unity 4 used? I'm curious how cached files differ to asset bundles and what, if any, different properties change from both types of files? I.E. What happens to asset bundles when they are cached through WWW.LoadFromCacheOrDownload?
Unity unfortunately doesn't have this process documented as the open source code calls an internal function called INTERNAL_CALL_WWW(this, url, ref hash, crc), which is given the instance of WWW, the string of the URL, a Hash128 and a UINT called crc with a default value of 0. (Referenced decompiled 5.3.2p2 code, 2017+ code is on the official Unity GitHub, but seems to differ from Unity 2015 code).
The Unity 2017 code leads to the private extern static IntPtr CreateCached(DownloadHandlerAssetBundle obj, string url, string name, Hash128 hash, uint crc); external method, which isn't documented either.
Furthermore, what actually happens when an asset bundle is cached so that the engine can recognise the file is in cache and doesn't need to be downloaded? Is it just simply that it searches for the hashed name in the cache, or does it do something more intricate?
Frostrix
I can clearly see the difference in size between created asset bundles (those to put on server to download later) and cached asset bundles (those downloaded once at runtime and stored to the device). On Windows you can find them at %appdata%/Local Low/Unity/company+name_of_app. Cached versions are typically less compressed so the app can load them faster, while those stored on the server are more compressed so it takes less bandwidth to download. The content should be the same, but compressed using different methods. See this docs page for more details.

IONIC 4: How to call iOs file resource from custom script within app

Here is the situation:
Ionic 4: (cli-5.2.7)
XCode 10.3
We have a custom eReader that lives in our assets folder.
When we want to download an eBook from our server and read it, we download the file and save it using the Native File plugin.
When we start up the reader, we send it the container in which we want the reader to be created and built, and an internal url to the file resource we want to read.
After window.Ionic.WebView.convertFileSrc, the file ref looks like:
ionic://localhost/_app_file_/var/mobile/Containers/Data/Application/[APP-ID]/Library/NoCloud/[BOOK-ID]/vol-001-chapter-006.xhtml
The reader will then build the iframe and send a simple XMHttpRequest to the provided url, then place the resulting html into the iframe.
The problem is that it only works on first load of the eBook from our server
I can see the file being downloaded, and written to its own folder in the apps file system (File.dataDirectory).
When I debug the XMLHttpRequest in our eReader.js, I can see the call being made to the resource and the HTML returning to the request, which is then rendered on the page.
BUT, if I close the app, reopen it, and try to access the already-downloaded book, the XMLHttpRequest in our eReader.js returns nothing.
I can verify that the file exists at the resource location after a reload, but the XMLHttpRequest acts like it cannot find anything at the provided location.
AND, this is only on iOs. Android works as intended.
My questions is, what am I missing? Is this something to do with the iOs permissions or persistence?
Any help would be appreciated.

Unity Asset Bundles Rebuilding with Old Data

I have a mobile project which displays various AR experiences to the user via a mobile application. This application is made in Unity.
Alongside this Unity project we have a second project that stores asset bundles exclusively. Each AR experience is a prefab marked with a unique asset bundle name. These bundles are stored online and downloaded into the main mobile application when relevant. We're having issues with having these bundles correctly update, when changing things on the prefab such as scale or rotation they aren't reflected in the rebuilt asset bundle.
Here's a look at the process we're using for rebuilding assets, It's only a simple script.
[MenuItem("Spiff/Build AssetBundles")]
static void BuildAllAssetBundles()
{
// BuildPlatformBundles(BuildTarget.iOS);
BuildPlatformBundles(BuildTarget.Android);
}
static void BuildPlatformBundles(BuildTarget platform)
{
// We convert the passed platform enum to a string.
string platformFolder = platform.ToString();
string assetBundleDirectory = "Assets/AssetBundles/" + platformFolder;
// Build our bundles out to the relevent platform specific folder.
if (!AssetDatabase.IsValidFolder(assetBundleDirectory))
{
AssetDatabase.CreateFolder("Assets/AssetBundles/", platformFolder);
}
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.None, platform);
}
Currently we use 'BuildAssetBundleOptions.None' We've also tried the ForceRebuild flag but this has no effect. Am I correct in assuming that Unity has some sort of internal cache it keeps for assets bundles? If so can we clear this somehow so I can ensure 100% that the bundle I am building is going to be the most up to date based on the prefab tagged with it?
Loaded Assetbundles are indeed cached, and will remain so until AssetBundle.Unload() has been called to free up all memory accociated with the asset.
After the asset has been unloaded a newer version of the assetbundle can be downnloaded and instantiated with the new values (Assuming the file downloaded has all the updated information), else it will load the data from cache if available.
On a side note: It seems like you're still using the old assetbundle pipeline. Unity has a plugin tool that makes the assetbundle workflow considerably easier called the assetbundle browser found here. It comes with a way easier UI for building bundles and inspecting bundles, open source and a very customisable pipeline. It may be worth checking out.
Like remy_rm mentioned, do give the Unity Asset Bundle Browser tool a try. It gives more control over what assets are in the bundle.
Your problem can be solved if you ensure two things:
1- When you make changes to a prefab and create a new bundle, is it indeed created with the said changes? (again using the tool would make checking this easier)
2- The bundles you are downloading in the main application are the new ones and not the old cached ones. In Unity Webgl for instance, you need to clear the browser cache to be 100% sure that the application downloads the new asset bundles and doesn't use the old ones in browser cache.

Getting SL to recognize Swift Object as Image... SoftLayer_Virtual_Guest_Block_Device_Template_Group/createFromExternalSource.json

SoftLayer support sent me to stackoverflow because they could not figure this out.
I have uploaded a VHD file to Swift object storage to import it as an Image. Because the image is larger than 2GB, I have uploaded all 2GB chunks and have created the appropriate manifest object in Swift to let me download the joined chunks. After uploading to Swift I can download the manifest URL and the MD5 for the uploaded file and the downloaded file match and I can boot the disk image locally. I do not have a Swift problem.
However, I can not get the SL portal or the API to consistently recognize my Swfit manifest object URI as a valid image. It works sometimes, but not others. I have tried making the Content-Type on the manifest object 'application/binary','application/octet-stream', and 'application/iso-9660-image' without success.
Typically I get a 500 error back from the:
SoftLayer_Virtual_Guest_Block_Device_Template_Group/createFromExternalSource.json
call with the error body: {"error":"The supplied file must be a image.","code":"SoftLayer_Exception_Public"}
Can anyone tell me definitively what the Content-Type should be (BTW curl uploads the chunks as 'application/x-www-form-urlencoded' and the manifest file as 'application/octet-stream') to make both the SL portal and the API work consistently?

Issue in streaming 360 videos in Unity for VR while using OzoPlayerSdk

I am facing problem in streaming videos on Ozo player sdk.
As per the documentation given I tried keeping http url in .playlist file
and in AppStateManager kept link for youtube in place for Server Url field.
The player on runtime indicates to download a video instead of streaming it and does nothing from the point.
Also it indicates of creating a .json file for Url provided in server url field.
Error i get is:
Starting download: https://www.youtube.com/videos.jsonUnityEngine.Debug:Log(Object)OZO.DownloadCache:DownloadFile(Uri, Boolean) (at Assets/Scripts/Data/DownloadCache.cs:93)OZO.VideoDownloadManager:GetVideosAsync(Uri, Action`1) (at Assets/Scripts/Data/VideoDownloadManager.cs:387)OZO.AppStateManager:Start() (at Assets/Scripts/App/AppStateManager.cs:127)
Failed to download: https://www.youtube.com/videos.jsonUnityEngine.Debug:LogWarning(Object)OZO.c__AnonStoreyA:<>m__D(String) (at Assets/Scripts/Data/DownloadCache.cs:189)OZO.Download:ReportComplete(String) (at Assets/Scripts/Data/Download.cs:183)OZO.Download:Cancel() (at Assets/Scripts/Data/Download.cs:243)OZO.Download:handleDownloadResponse(UnityWebRequest, Download) (at Assets/Scripts/Data/Download.cs:330)OZO.c__Iterator0:MoveNext() (at Assets/Scripts/Data/Download.cs:315)UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
Failed loading video entriesUnityEngine.Debug:Log(Object)OZO.AppStateManager:onVideoListDownloaded(Dictionary`2) (at Assets/Scripts/App/AppStateManager.cs:134)OZO.c__AnonStoreyC:<>m__10(String) (at Assets/Scripts/Data/VideoDownloadManager.cs:363)OZO.Download:ReportComplete(String) (at Assets/Scripts/Data/Download.cs:183)OZO.Download:Cancel() (at Assets/Scripts/Data/Download.cs:243)OZO.Download:handleDownloadResponse(UnityWebRequest, Download) (at Assets/Scripts/Data/Download.cs:330)OZO.c__Iterator0:MoveNext() (at Assets/Scripts/Data/Download.cs:315)UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
Please help on the same. Step by step procedure for the same would be helpful.
Also need to know what features we get to use in paid version of sdk.
For the record the HTTP stream has to respect the MPEG-DASH format with AVC1 or AVC3 codec (this is what the SDK supports). That means the format of the URL has to end with a .mpd
example: http://vm2.dashif.org/livesim-dev/periods_60/xlink_30/insertad_1/testpic_2s/Manifest.mpd
I don't know what format you used but if it tries to download, you probably don't have the right format.
If you want to deliver youtube videos as DASH, I advise you to read this: https://developers.google.com/youtube/v3/live/guides/encoding-with-dash
BUT I have been talking to the dev team of the SDK as I also cannot read my stream (though it does not try to download it) and have been told that there is currently a problem which makes the whole streaming part unsuable. They should release a fix ASAP (though they did not give me a date).