Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Android game crashes on scene loads (Inflate error/signal 11 (SIGSEGV))

Discussion in 'Android' started by Jessespike, Aug 14, 2012.

  1. Jessespike

    Jessespike

    Joined:
    Jul 9, 2012
    Posts:
    44
    Hello,

    I have a crashing problem that I been trying to solve for a few weeks now and I'm stumped. The problem happens when trying to switch scenes in a game. It only freezes/crashes on the device and it only during or immediately after a scene is loaded. It won't crash at the same time either. Sometimes I can switch scenes 6 times until it crashes, sometimes it won't happen after 20 scene loads. I have two devices, a Samsung Galaxy tab and some Samsung phone (sorry not near me atm).

    I logcat the crash and it repeats this error, or something similar:

    Sometimes the error is slightly different, but it always happens on the same ZipFile line.

    E/Unity ( 2122): Inflate Error: invalid block type
    E/Unity ( 2111): Inflate Error: too many length or distance symbols

    I understand the problem could be caused from many things. So I did my best to narrow it down. I usually found Low Memory warnings in the logcat reports, and so dealing with any memory leaks seemed like a good start. I removed every script from the game, incase objects were being created and not destroyed. I left one script on a empty game object in the "Title" scene, which is only loaded once. The script sets the GameObject to DontDestroyOnLoad and is basically a timer that iterates through the scenes, like this:

    Title -> Main -> Level1 -> Main -> Level2 -> Main --> *Repeat back to Level1*

    This is so I could test scene loads, try fixes and get reports more quickly. Some of the things I tried to narrow it down:

    • Removing all the scripts didn't work
    • Made a "Loading Screen" scene that's basically an empty scene with a script that waits for Resources.UnloadUsedAssets to finish, and then tries to load the next desired scene.
    • Removing meshes, animations, and audio from the scenes. This made the scenes file size smaller as expected, and only delayed the crashes.
    • Removing plugins
    • Setting every shader to something simple like "Unlit/Texture"
    • Tried on different Unity versions; ( 3.4.2f, 3.5.2f, 3.5.5 )
    • Tried different Androids ( 2.3.3 and 4.0.3 )

    While researching the problem and trying tests within Unity, just in case it wasn't something I was doing wrong in Unity. According to online research, I believe the issue is I'm losing the eglContext or ANR (Activity not responding), I'm not sure why or what I'm doing wrong. Any insights would be great.

    See here for more logcat details

    In eclipse/logcat, if I filter just errors, I get:

    If I remove textures, the crash is delayed. but it will still happen. Just not as soon.
    If anyone knows how to deal with this issue and needs further information, I'll be glad to provide it (tombstones, manifests, etc).
     
    Last edited: Aug 18, 2012
  2. Phil-AV

    Phil-AV

    Joined:
    Jul 9, 2012
    Posts:
    57
    Speaking from experience of solving sigseg's (what we call them in the office), im 99% sure your problem stems from the eclipse side of things and is usually related to your unity<-> java code. Either you've missed out a step in the interfacing on the c# side or unity is tying to access something that doesn't exist in the java code.

    I can't tell for sure but that's usually the first place I look when the ol' sigseg appears.

    I know i'm being of little help, but this is the only scenario I've encountered sigsegs (that and a horrendous bug stemming from playing sound on a dual core device, which was found in a few of our non-unity android games).
     
    Last edited: Aug 14, 2012
  3. Jessespike

    Jessespike

    Joined:
    Jul 9, 2012
    Posts:
    44
    Wow! Thanks ALOT Phil! That did it!
    You were correct, I was sub-classing the Unity activity incorrectly. Can't tell you how happy I am, :)

    I also noticed that the issue persists if I tried to use Gingerbread OS, but ICS works OK now.
    I think the difference is the lack of eglPreserveContextOnPause in 2.3.3, (API 10). Is there any way around this? If not, would it be possible to restart the UnityPlayer activity and try to load/resume where it left off? This is also on the Samung Galaxy Tab, and from browsing on the forums, seems like that hardware can be finicky..
     
    Last edited: Aug 18, 2012
  4. Nolex

    Nolex

    Joined:
    Dec 10, 2010
    Posts:
    107
    Hi! I have a same problem. My game freezes when loading a level(sometimes) on devices.

    Settings:


    Thanks for the in-depth analysis, but I do not understand how you fix this problem.
    What exactly was the problem?
     
  5. jasons

    jasons

    Joined:
    Oct 14, 2011
    Posts:
    10
    I'm having the same "Inflate error" problem.

    This is happening on my Rena 3 android 2.3.5 tablet. Android 4.x devices seems fine.

    I'm using Unity Pro 3.5.7f6
    I'm using several Prime31 plugins: Flurry, IAP, MoPub, SocialNetworking
    I'm using Resources.Load() to load/unload several files (i.e several 8Mb 2048 sprite atlases, fonts, text assets, and more) during scene changes.

    My player settings are Android 2.2 Froyo API 8, armv7, OpenGL ES 1.x, prefer external, auto, internal only, net 2.0 subset

    I'm thinking there could be a problem with one or more of the plugins I'm using, or perhaps an issue with Unity3d's Resource.Load memory management.

    I have a simple automated scene switcher to help test (similar to what jessespike described). I'd like to stick this script into a Unity3d example project that makes heavy use of /Resources/, unfortunately I couldn't find one? (angry bots, bootcamp and cars demo, don't use /Resources/ much).

    Tomorrow I will probably try copy my project to a test folder, and strip out all the plugins, and see how that behaves.

    Jessespike and Nolex, trying to figure out what we have in common. Can you respond to these questions:
    + if you make use of 3rd party plugins (i.e. Prime31) and which ones?
    + do you use lots of Resources.Load() and Unload() calls?
    + does this error happen to you on multiple devices? I only have one 2.3.5 device, and its happening on that. Perhaps it could be flakey ram on our device?.
     
  6. jasons

    jasons

    Joined:
    Oct 14, 2011
    Posts:
    10
    Hi Nolex, are you having the same "Inflate error"?

    If you have the android device plugged into your macosx usb you can open a terminal window, go to your ~/android-sdk-macosx/platform-tools/ folder, and run "./adb logcat -s Unity" to print out logcat debug messages from your device to the console. When the scene loading freezes for me and jessespike the console will print some error containing "Inflate error" over and over.
     
  7. Nolex

    Nolex

    Joined:
    Dec 10, 2010
    Posts:
    107
    1) No. No plug-ins
    2) Not use
    3) myltiple.. On device 2.3.7 and Android 4.0

    I know and have done.

    Code (csharp):
    1. E/Unity ( 8707): Inflate Error: invalid block type
    2. E/Unity ( 8707):
    3. E/Unity ( 8707): (Filename: PlatformDependent/AndroidPlayer/ZipFile.cpp Line: 234)
    4. E/Unity ( 8707):
    5. E/Unity ( 8707): Inflate Error: invalid block type
    6. E/Unity ( 8707):
    7. E/Unity ( 8707): (Filename: PlatformDependent/AndroidPlayer/ZipFile.cpp Line: 234)
    p.s. I`m using Unity 3d 3.5.2f2
     
    Last edited: Jan 1, 2013
  8. Nolex

    Nolex

    Joined:
    Dec 10, 2010
    Posts:
    107
    I updated to last 3.5.x version — 3.5.7.
    The problem was not resolved:

    Code (csharp):
    1. 01-02 10:46:11.267: E/Unity(9997):  
    2. 01-02 10:46:11.267: E/Unity(9997): (Filename: PlatformDependent/AndroidPlayer/ZipFile.cpp Line: 234)
    3. 01-02 10:46:11.287: E/Unity(9997): Inflate Error: invalid stored block lengths (file zip crc32 : 6e5ee8be)
    4. 01-02 10:46:11.287: E/Unity(9997):  
    5. 01-02 10:46:11.287: E/Unity(9997): (Filename: PlatformDependent/AndroidPlayer/ZipFile.cpp Line: 234)
    6. 01-02 10:46:11.287: E/Unity(9997): Inflate Error: invalid stored block lengths (file zip crc32 : 6e5ee8be)
    7. 01-02 10:46:11.287: E/Unity(9997):  
    8. 01-02 10:46:11.287: E/Unity(9997): (Filename: PlatformDependent/AndroidPlayer/ZipFile.cpp Line: 234)
     
  9. jasons

    jasons

    Joined:
    Oct 14, 2011
    Posts:
    10
    Well, I stripped out all plugins and use of Resource folder, and still get the error.

    I'm also reasonably sure that my code is not responsible. I've literally disabled everything in the game hierarchy except my auto scene loader, and it still errors. I'm pretty sure my scene loader isn't to blame (I used 2 different versions just to be sure).

    I decided to modify the Penelope demo. I created a scene #0 that contains nothing but my scene switcher game object (that uses a DontDestroyOnLoader()) that simply switches between scene #1 (a completely empty scene) and scene #2 (EmeraciteMine scene). Even that Penelope demo causes an error. The first time I ran it went through 60 load "cycles" before erroring, the 2nd and 3rd attempts went to 150-250 cycles before erroring. My scene loader also prints out the memory usage (I'm using System.GC.GetTotalMemory(true) for that) and it doesn't seem to be leaking memory between cycles.

    I thought perhaps that some of the dynamically generated cache files in the projects "Library/" sub-folder could be corrupted, so I deleted the "cache", "metadata", "previews" and "ScriptAssemblies" subfolders, but that did not fix it.

    I removed calls to System.GC.Collect() which I do between some scene changes. No fix.

    I'm using a non-stock Android rom on my device. So, perhaps that is not as stable as it appears to be.

    I'm running out of ideas. I may try a upgrading to Unity 4.0 but will need to read up on breaking changes before I do that. I may load another 2.2.x or 2.3.x rom and see how that goes.

    Edit: I just did a "development build" on the penelope test, and got to 500+ cycles WITHOUT crashing, before I decided to end the test and go to bed. I'm satisfied that there is nothing wrong with my code. Its either a problem with unity, my android rom, or the combination of the two.
     
    Last edited: Jan 3, 2013
  10. jasons

    jasons

    Joined:
    Oct 14, 2011
    Posts:
    10
    Rolling back to a 2.2.1 rom on my device was enough to end the errors.
     
  11. Bill-Robinson

    Bill-Robinson

    Joined:
    Sep 21, 2012
    Posts:
    6
    FWIW We're getting a lot of these error reports of this in our live game. It is erroring on a call to Resources.Load on some of the larger textures.

    They're a mixture of these errors:

    Inflate Error: invalid block type
    Inflate Error: invalid literal/length code
    Inflate Error: invalid distance code
    Inflate Error: invalid code lengths set
    Inflate Error: invalid stored block lengths

    These are approximately the top devices with this report:

    LGE Nexus 4
    samsung GT-I9300
    asus Nexus 7
    samsung GT-I9100
    samsung GT-N7000
    samsung GT-P5210
    samsung SM-N9005
    samsung SPH-D710
    samsung GT-I9505
    samsung GT-I9500

    The OS is all Android 4+ and built with Unity 4.3.2

    Maybe it's some kind of out-of-memory error that is not handled correctly in Unity's Resources.Load implementation having a knock-on effect and corrupting the resource while it is loaded.

    Anyone else have any wisdom to share on this subject?
     
    kyubuns likes this.
  12. ohmyhead

    ohmyhead

    Joined:
    Jan 14, 2014
    Posts:
    4
    The same problem.

    E/Unity ( 3046): [PlatformDependent/AndroidPlayer/Source/ZipFile.cpp line 254]
    E/Unity ( 3046): (Filename: D Line: 0)
    E/Unity ( 3046):
    E/Unity ( 3046): Inflate Error: invalid code lengths set (file zip crc32 : ec0033c5)
    E/Unity ( 3046): UnityEngine.Resources:Load(String, Type)
    E/Unity ( 3046): UnityEngine.Resources:Load(String)

    I have to release resources frequently in this project.
    The OS is Android 4.4.2 and bult with Unity4.5.5.
    I don't know how to avoid it.
    Has not a solution?
     
    kyubuns likes this.
  13. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    60
    exitsimulation likes this.
  14. V1nsaN

    V1nsaN

    Joined:
    Jan 16, 2013
    Posts:
    6
    Hi there. I have some strange issue. My app on xiaomi mipad crashes on loading scene (when 2048x2048 texture is loads). Very strange. Enybody could help me? I am using Unity 5.0.1f1 and I didn't try 4.6.1p1 yet (maybe with this version everything will be fine). Btw. on my nexus 4, HTC One X+ and HP Touchpad with CM 10 everything is fine.
     
unityunity