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 simubrett · Jul 03, 2012 at 06:35 PM · androidloadingloadlevelasync

LoadLevelAsync Crash on Android

I have a (very simple) loading screen implemented, and it works flawlessly on iOS and web builds. Unfortunately, it causes a crash 100% of the time on Android builds. On a non-Development Build, some loading takes place before the crash (about 60-70%), but if I make a Development Build, the crash occurs as soon as my loading screen is shown. If I remove the loading scene, the game runs fine on all platforms, barring a watchdog kill.

I recognize that this may not be a LoadLevelAsync crash. There may be some asset that is unable to properly async-load only on Android, but since I can't get any messaging out of LoadLevelAsync to let me know what is being loaded when the crash occurs, I'm flying blind. Any debugging tricks for this situation for a moderately-sized game would be appreciated as well.

Here's my loading code. This is placed on an object in the loading scene.

 public string LevelToLoad;
 AsyncOperation async;

 IEnumerator Start()
 {
     //Debug.Log("Started Loading...");
     async = Application.LoadLevelAsync(LevelToLoad);
     yield return async;
 }

 void Update()
 {
     //Debug.Log("Loading Progress: " + async.progress * 100);
 
     //ProgressSprite is an object of a custom loading sprite class, 
     //but contains no surprises.
     ProgressSprite.fillAmount = async.progress;
 }
Comment
Add comment · Show 5
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 Kryptos · Jul 03, 2012 at 07:15 PM 0
Share

To help us debug your issue, uncomment the Debug.Log in Update and tell us how many lines were printed before the crash.

avatar image simubrett · Jul 05, 2012 at 07:15 PM 0
Share

It successfully runs until about 67%, which takes a little over 5 seconds.

avatar image Kryptos · Jul 05, 2012 at 09:36 PM 0
Share

Yes but how many occurrences of the debug.log message?

avatar image simubrett · Jul 06, 2012 at 05:30 PM 0
Share

Over a hundred. Is there some particular merit in knowing an exact number of which I'm not aware?

avatar image Kryptos · Jul 06, 2012 at 09:13 PM 0
Share

Yes if you only got one I could mean that it was some kind of NullReferenceException.

2 Replies

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

Answer by simubrett · Jul 06, 2012 at 05:40 PM

I found the following discussion to be a useful direction to search in: Dealing With Large AssetBundles

Thinking that I might just be loading too much at once for Android, like the folks in that thread, I chopped out my audio resources (which happened to bring the rest under 20MB), and the game loads fine. Now I need to see if I can bundle the audio separately and differently, or if it's somehow a problem with the audio itself.

Comment
Add comment · Show 1 · 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 simubrett · Jul 09, 2012 at 09:34 PM 1
Share

Yep, this did it. By chopping out my audio resources and adding them to an AssetBundle that I load up at runtime, I'm able to avoid this crash. Looks to be a bug in Unity that the crash is happening at all.

avatar image
0

Answer by Kryptos · Jul 03, 2012 at 07:11 PM

I don't think that is the cause, but you should always guard any reference against NullReferenceException. Thus:

 void Update()
 {
     if( async == null )
         return;

     // add a test here to check whether the ProgressSprite is ready, because if this script is executed first it can crash here
     //...
     ProgressSprite.fillAmount = async.progress;
 }
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 Mortoc · Jul 05, 2012 at 09:50 PM 0
Share

I don't think you should always guard against null. In cases where it's impossible to get a null, it's prolly ok not to add that extra branch.

avatar image Kryptos · Jul 06, 2012 at 07:42 AM 0
Share

Sorry to disappoint you. But it is very probable to get a null in this case: if LevelToLoad does not match a level that has been added to the build list, then Application.LoadLevelAsync will return null.

Testing for null value is a very quick test (only one CIL instruction) and should always be done. You should never infer that "in this case it is impossible". That's when bugs occur.

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

6 People are following this question.

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

Related Questions

LoadLevelAsync problem in Android with Unity 3.5.2 0 Answers

Help with Exception: Error building Player on Android 2 Answers

Android load/unload times 0 Answers

loading wheel on splash on android 0 Answers

JSON file not written/read on application exit on android 1 Answer


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