Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by timothykimball · Sep 09, 2014 at 01:07 PM · networkingiphoneassetbundle.loadasync

Using LoadFromCacheOrDownload causes iOS to freeze/stall

We have the below code. On Android, the code reports a smooth progress from 0 to 1. On iOS, it jumps straight from 0 to 1. This is also exhibited in the foreground as when we load the asset bundle for the first time the whole app freezes until the bundle successfully loads.

A couple of things to consider:

  • The problem is iOS specific. it works on every other platform. -we do not ship for webplayer

  • It successfully loads the assets on iOS - so definitely built for the platform

  • We download assets over the internet in this particular situation, so we are not loading from streaming assets

  • When we download, we save to a location on disk. Only after the content is 100% downloaded do we then load the bundle.

  • Said another way: WWW.LoadFromCacheOrDownload is given a local path to load the bundle from

  • Line 10 is yield every frame NOT every cpu cycle. So it is not maxing out the CPU.

  • To reiterate: The below code loads the bundle correctly - it just does not report on progress in a granular way AND the app freezes while loading the bundle

What we would prefer to see is a loading process that is smoother - allowing us to at least show a graduated progress bar or whirly gig.

Why is this? Is there anything we can to do mitigate?


var threadPriority = priority == AssetPriority.Foreground ? ThreadPriority.High : ThreadPriority.Low;
Application.backgroundLoadingPriority = threadPriority;
using (var www = WWW.LoadFromCacheOrDownload(url, 1)) {
    Trace.Log(string.Format("{0} {1} Priority: {2}", LocalPackagePath, ContainerPath, priority));
    www.threadPriority = threadPriority;
    Application.backgroundLoadingPriority = www.threadPriority;
    Trace.LogDiag(string.Format("{0} STARTING LoadFromCacheOrDownload", LocalPackagePath));
    Script.StartCoroutine(RunWWW(www));
    do
    {
        yield return 0;
        Trace.LogDiag("Progress: " + www.progress);
    } while (!www.isDone && String.IsNullOrEmpty(www.error));
    Trace.LogDiag(string.Format("{0} END LoadFromCacheOrDownload", LocalPackagePath));
    if (!String.IsNullOrEmpty(www.error) || www.assetBundle == null) {
        // we received an error loading the bundle
        // as the bundle is local, chances are the bundle is corrupted by something.
        // We delete and move on...
        Trace.LogError(string.Format("{0} Error loading bundle @ {1}: {2}", LocalPackagePath, ContainerPath, (String.IsNullOrEmpty(www.error) ? "Unknown" : www.error)));
        yield break;
    }
    Bundle = www.assetBundle;
    Bundle.name = ContainerPath;
}
... and:


private IEnumerator RunWWW(WWW www)
{
    yield return www;
}

Comment
Add comment · Show 7
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image David-Berger ♦♦ · Feb 06, 2015 at 02:49 PM 0
Share

Does it work properly when you load the Assets from your local Streamed Assetbundles folder (Application.strea$$anonymous$$gAssetsPath) did you ensure the asset bundles you load are built for iOS properly rather than for Android? Have you set a correct CrossDomain.xml (probably yes as it works for Android, but you never know)

avatar image Graham-Dunnett ♦♦ · Feb 06, 2015 at 03:21 PM 0
Share

Isn't the line 10 do loop just maxing out the CPU?

avatar image timothykimball · Feb 08, 2015 at 05:19 PM 0
Share

To answer your questions:

  • The problem is iOS specific. it works on every other platform.

  • I thought CrossDomain.xml is important for Webplayer - we do not ship for webplayer

  • It successfully loads the assets on iOS - so definitely built for the platform

  • We download assets over the internet in this particular situation, so we are not loading from strea$$anonymous$$g assets

  • Line 10 is yield every frame NOT every cpu cycle. So it is not maxing out the CPU.

avatar image David-Berger ♦♦ · Feb 23, 2015 at 04:07 PM 0
Share

For me this looks like a bug. Please create a $$anonymous$$imal reproducible and file a bug report!

avatar image Eric Laberge · Mar 29, 2015 at 08:23 PM 0
Share

We are getting hit by this bug also. I reported the bug along with a simple demo project, bug #684964.

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by David-Berger · Apr 13, 2015 at 04:37 PM

I reproduced and verified the issue based on #684964. At the moment this behaviour is by design, we might however review it and see if we can change it in future! Thanks for bringing this to our attention.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image cristivp · May 05, 2015 at 01:32 PM 0
Share

We are facing the exact problem. Has there been any progress in fixing this issue?

avatar image David-Berger ♦♦ · May 13, 2015 at 02:03 PM 0
Share

It's on our investigate list and has developer attention, but no ETA yet.

avatar image David-Berger ♦♦ · Apr 22, 2016 at 05:01 PM 0
Share

@cristivp @timothykimball this should be fixed in the latest 5.4 beta. Please give it a go.

avatar image
0

Answer by Dave-Hampson · Feb 11, 2015 at 09:03 PM

I've seen a situation like this before where it was actually the server not sending the 'Content-Length' parameter, but only to a particular device (iOS if I remember correctly).

Odd, and completely confusing when diagnosing the problem! Might be worth either trying a different http server where you can view the headers, or getting a packet sniffer to rule this out.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image timothykimball · Feb 11, 2015 at 09:35 PM 0
Share

We download via the server and save locally BEFORE loading. We then load per the code above. I have revised the description to include this information.

avatar image Dave-Hampson ♦♦ · Feb 11, 2015 at 09:45 PM 0
Share

Ok not the situation I've seen then. One course of action would be to file a bug if you think that you have a good repro case for the iOS version being broken.

avatar image
0

Answer by nanusorn · Jan 26, 2017 at 08:47 AM

Finally, this attached url fixed above issue I also faced. https://forum.unity3d.com/threads/appname-was-compiled-with-optimization-stepping-may-behave-oddly-variables-may-not-be-available.372705/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

networking, iPhone ... cellular / 3G woes ?? 1 Answer

Unity 3d Network dies on Android 0 Answers

Image-based Level Generator having problems 0 Answers

Bump API for Unity 4 0 Answers

Why can Android send commands via NetworkManager but iOS cannot? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges