Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

2-5x increase in crashes from Samsung devices on Android 4.4.2

Discussion in 'Android' started by tayl0r, May 15, 2014.

  1. tayl0r

    tayl0r

    Joined:
    Jan 6, 2012
    Posts:
    74
    @Unity Devs

    My app has over 100k dau on Android (so a very high sample size) and I'm seeing a huge increase in crashes from devices running Android 4.4.2. The same device, the same application version, the only difference is the OS version- and the crash rate is literally 2-5x higher once the device upgrades to Android 4.4.2.

    I'm already using 32 bit display buffer, *not* using multithreaded rendering or OpenGL 3.0, so those things are not the issue.

    I see that NGUI has an Android 4.4.2 crash that might be the same thing (http://www.tasharen.com/forum/index.php?topic=8415.0) but I'm using 2D Toolkit (and some of the built in Unity 3d shaders + 3d meshes, Ragespline, lots of other home built stuff too), not NGUI, and no one else on the tk2d forums is reporting this so I thought I would post here first. The NGUI crash from that thread is related to resizing the number of verts in a VBO.

    Here is all the info I can get from Crittercism:

    Crash Reason:
    Code (csharp):
    1. signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 7bf28700 Build fingerprint:
    2. 'Verizon/jfltevzw/jfltevzw:4.4.2/KOT49H/I545VRUFNC5:user/release-keys' Revision: '11' pid: 771, tid: 789,
    3. name: UnityMain >>> com.MyOrgName.MyBundleId <<<
    4. r0 7bf28700 r1 832499e0 r2 000001c0 r3 00000000 r4 000001c0 r5 7791b994 r6 7bf28700 r7 832499a0 r8 000001c0 r9 00000001 sl 000001c0 fp 00000001 ip 00000006 sp 7791b918 lr 75fdf10b pc 4007e27e cpsr 0000000b
    5.  
    Crashed Thread:
    Code (csharp):
    1. java.lang.Error: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 849fb700
    2. Build fingerprint: 'Verizon/jfltevzw/jfltevzw:4.4.2/KOT49H/I545VRUFNC5:user/release-keys'
    3. Revision: '11'
    4. pid: 5915, tid: 5932, name: UnityMain >>> com.MyOrgname.MyBundleId <<<
    5. r0 849fb700 r1 781f3880 r2 000001c0 r3 00000000
    6. r4 000001c0 r5 77954994 r6 849fb700 r7 781f3840
    7. r8 000001c0 r9 00000001 sl 000001c0 fp 00000001
    8. ip 00000006 sp 77954918 lr 7601710b pc 4009327e cpsr 0000000b
    9. at libc.__memcpy_base(__memcpy_base:261)
    10. \at Unknown.ffffffff(Unknown Source)
    The NGUI thread mentions that the crash is inside of the PowerVR driver when it tries to do a memcpy, and memcpy is the reason for this crash here as well, so that's why I think it might be the same thing.

    Any ideas?
     
  2. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
    Do OpenGL 3.0 build for those Adreno 320 and Adreno 330 devices.
    or
    Wait for new Unity release
    or
    Blacklist all devices with Adreno 320 or Adreno 330 GPUb

    https://github.com/opensciencemap/vtm/issues/52
     
  3. johnnydj

    johnnydj

    Joined:
    Apr 20, 2012
    Posts:
    211
    all my games are using NGUI, and I have a Note3.
    all my builds are for OpenGL 2.0
    never had any crashes in any of my games.

    What I did find out once, was that NGUI 3.5.3 crashed on the device after like 1 minute of playtime.
    This happened only on Android 4.4.2
    What fixed the issue for me was to use NGUI 3.4.9
    It is the most stable version for me and getting 0 crashes on any Android version.
     
  4. Radiangames

    Radiangames

    Joined:
    Sep 15, 2011
    Posts:
    16
    I'm having the same issue. Lots of Samsung-based devices are crashing when using Android 4.4.2. In one game, it seems to crash instantly, but in others it can take a few minutes. I do a lot of mesh-resizing in my script, as the entire game engine is driven by that. I've downgraded to past versions of Unity (down to 4.1.5), used the 32-bit buffer fix, and nothing works.

    What is an alternative to using a dynamically resizing mesh to do a massive amount of 2D drawing with a single texture (spritesheet)? I'm serious, as that's the only way I've ever done it in Unity.
     
  5. killerbean

    killerbean

    Joined:
    Sep 12, 2011
    Posts:
    35
    Try checking for NullReferenceException's in the Console. Last year I noticed that when the Samsung S4's came out, they would immediately crash when a NullReferenceException was encountered.

    I had to play through the entire game in the Editor, waiting for these errors to happen. Then going into the scripts to fix the errors.


    To fix these errors, just say something like:

    if (Variable)
    {
    do something with Variable;
    }

    Instead of just saying "do something with Variable;" If the variable is null, then it will cause the crash in the S4. So you have to make sure the variable is not null before you do anything with it. Hope that helps!
     
  6. Russel

    Russel

    Joined:
    Oct 12, 2011
    Posts:
    40
  7. gdeglin

    gdeglin

    Joined:
    Mar 7, 2013
    Posts:
    78
    +1 Same problem here with a 4.4.4 device
     
  8. KMKxJOEY1

    KMKxJOEY1

    Joined:
    Jan 2, 2013
    Posts:
    10
    4.4.4 Nexus 5 has the same problem, although my app doesn't use NGUI

    To killerbean's fix, has this been confirmed? I'm pretty sure my app doesn't have any null pointer exceptions at any point
     
  9. zibizz1

    zibizz1

    Joined:
    Oct 11, 2012
    Posts:
    16
    Our game don't work on any samsung tablet with android 4.4.2. There are crashes, and nullreferenceexcepition.
    In stacktrace we have path of code that is no able to execute. In some getter, execution of code jumps to setter that is no there. It looks like something changes adresses on stack. We can avoid this behaviours by removing virtual/override methods/properties in places causing these errors but we can't do it in whole project.

    Also game works well on iPads, iPhones and variety of android devices.

    We have also problems with Xperia z2 and OnePlus One. They are crashing when loading scenes or loading asset bundles with heapcoruption error.
     
    Last edited: Sep 8, 2014
  10. Unarmed1000

    Unarmed1000

    Joined:
    Sep 12, 2014
    Posts:
    17
    This seems to be the exact issue I have been encountering as well. I tracked down the issue to this code

    Code (CSharp):
    1. ShadowTag RegisterObject(int classId, IShadowable obj)
    2. {
    3.   ShadowTag tag = new ShadowTag(obj, classId, NULL_ID, 0);
    4.   int objectId = m_objectList.Add(tag);
    5.   tag.ObjectId = objectId;
    6.   obj.SYS_Tag = tag;
    7.   if (tag == null)
    8.     throw new Exception1();
    9.   if (obj.SYS_Tag == null)
    10.     throw new Exception2();
    11.   return tag;
    12. }
    13.  
    Where Exception2 keeps firing.

    Meaning the "obj.SYS_Tag = tag" assignment a couple of lines above seem to be failing and SYS_Tag is a property on a interface (and the implementation just stores the value).

    On my games I see the crashes on
    • Samsung Galaxy Note 3
    • Samsung Galaxy S5
    • Google Nexus 5
    • Samsung Galaxy Tab 4
    • HTC Verizon One (HTC M7)
    • Samsung SGH-I337
    • HTC One (M8)
    • Samsung Nexus 10
    • Samsung Galaxy S4
    • HTC PN071

    It occurs on Unity 4.5.4.

    It could be related to this issue:
    http://forum.unity3d.com/threads/unity-apps-crashing-on-samsung-galaxy-s4.183444/
    At least it sounds like unity handles things differently on the S4 than on most other phones


    I just send a bug report.
     
    Last edited: Sep 14, 2014
  11. Unarmed1000

    Unarmed1000

    Joined:
    Sep 12, 2014
    Posts:
    17
    I just acquired a device where I can trigger the issue 99% of the time when running 4.5.5 using a debug build of the game.

    Android 4.4.4
    On a Sony Xperia Z1 Compact D5503
     
  12. Unarmed1000

    Unarmed1000

    Joined:
    Sep 12, 2014
    Posts:
    17
    Now that I can reproduce the bug I could also verify that changing the IShadowable interface to be a abstract class removes the issue.

    So Unity3D does appear to have a issue with properties on interfaces on certain android devices. This is quite worrying.
     
  13. cgJames

    cgJames

    Joined:
    Dec 3, 2014
    Posts:
    30
    We have had similar symptoms when testing Android built with Unity 4.5.5. In a fairly reproducible case (~75%) our game will crash with Fatal signal 11 (SIGSEGV) having first logged an error from Unity. The Unity stacktrace shows a code path that should not (cannot) happen. Static analysis finds no call from one method in the stacktrace to the next. As @zibizz1 says, it's as though the code/stack has been altered on device.

    Here is a list of the devices we have tested on:

    Crashed
    • HTC One M8 (Android 4.4.4)
    • Google Nexus 5 (Android 4.4.4)
    Did not crash
    • Kindle Fire (2nd Gen)
    • Kindle Fire HDX 8.9 (3rd Gen) (Fire OS 4.5.1)
    • Samsung Galaxy S3 (Android 4.3)
    • Samsung Galaxy Note 2 (Android 4.3)
    • Samsung Galaxy Note 8.0 (Android 4.4.2)
    • Xiaomi Redmi Note (Android 4.2.2)
    We will investigate @Unarmed1000 's interface idea and report back. We'll also be testing on some more devices in the next few days so I'll update with more info.

    As yet we've not been able to distil the problem into a 100% reproducible test project.

    Does anyone from Unity have any comment?
     
  14. cgJames

    cgJames

    Joined:
    Dec 3, 2014
    Posts:
    30
    We've since tested on Samsung Galaxy S5 (Android 4.4.2) and the Nexus 5 (4.4.4). They both crash.

    We have noticed that switching runtime from Dalvik to ART stops the problem BUT upgrading the Nexus 5 to Android 5.0.1 (which has ART enabled by default) makes the crash occur more frequently.
     
  15. zibizz1

    zibizz1

    Joined:
    Oct 11, 2012
    Posts:
    16
    This issue crashes also:
    • HTC One M8
    • HTC One M7
    • LG G3
      switching to ART stops the problem
      @cgJames on most Nexus devices with Android 5 every NullReferenceException is crashing game. It was apparently solved in 4.6.1p4
     
  16. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    I suggest everyone upgrade to 4.6.2 unity and retest.
     
  17. zibizz1

    zibizz1

    Joined:
    Oct 11, 2012
    Posts:
    16
    4.6.2 nothing changes it looks like Snapdragon 800-801+ Android 4.4 is the problem (Galaxy S5, LG G3, HTC One M8)
     
  18. zibizz1

    zibizz1

    Joined:
    Oct 11, 2012
    Posts:
    16
    switching to OpenGL 3.0 or Automatic can also solve this problem
     
  19. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    461
  20. cgJames

    cgJames

    Joined:
    Dec 3, 2014
    Posts:
    30
    There seem to be a lot of NullReferenceException reports, some with SIGSEGV. The one I refer to is where Unity/Mono executes code that should not be called and subsequently crashes. I submitted a bug report (655263) and Unity QA have been able to reproduce. It's been forwarded to the dev team.
     
  21. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Did you try Unity 4.6.2p2?
     
  22. cgJames

    cgJames

    Joined:
    Dec 3, 2014
    Posts:
    30
    Yep, and Unity 5 RC1. Unity QA confirmed the bug on Friday (13th Feb) so hopefully they're working with the most recent version of Unity too.
     
  23. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    461
    Great to hear, as this could potentially explain some secondary crashes we are seeing in the wild that we have been unable to reproduce on our in-house test devices.
     
  24. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Well I hope for 4.6.2patch3 this Thursday to solve this issue.
     
  25. cgJames

    cgJames

    Joined:
    Dec 3, 2014
    Posts:
    30
    I hope so too. The devices it affects are very popular, the bug is ridiculously difficult to reproduce in a small, submittable project and the outcome is confusing. All that combined makes for a bug that could easily get lost or mistaken for something else. The fact that code gets "changed" at runtime is just plain scary. You don't know what to trust and can't easily work around it. @MrEsquire I'd like a Thursday fix too, but I fear this one might go deep. I hope I'm wrong.
     
  26. cgJames

    cgJames

    Joined:
    Dec 3, 2014
    Posts:
    30
    The bug now exists in issue tracker. I'm sure getting this bug fixed will stop a lot of random crashes on flagship devices running Kitkat. I've checked and the fix schedule is unknown so please head over to issue tracker and up vote it!
     
  27. Pelukeiro

    Pelukeiro

    Joined:
    Jul 6, 2013
    Posts:
    4
    I have the same issue in unity 3.5.7, but is only happening in Notes 4 Devices (just when it loads), app is compatible with opengl 1.1 and 2.0. and I tested it's ok on Chinese phones, xperia x10 mini (old) nexus 4 with android 5.0.1 and Galaxy S5 without issues.

    I was wondering in update to last version of unity but I see all is wrong hehe, should be maybe the touchwiz of the notes 4 the issue?
     
  28. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    993
    Is this fixed, or can we get a status update?

    I just had a user alert me to an app startup crash on a Samsung Galaxy Note 4 , SM-N910V which uses a Qualcomm Snapdragon 805.

    Other devices seem aok, no other users reporting crashes or crashes in Google console.
     
  29. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,051
    Not sure if this is related but I've been struggling with memory crashes on my current project. The game runs fine on my Samsung Note 8.0 tablet (with 2GB RAM) that is running 4.1.2. However, the exact same code crashes due to an out of memory error on my Note 3 (with 2GB RAM) that is running 4.4.2. It also crashes due to a memory issue on a S4 running 4.4.2 as well.

    I know it's a memory issue because if I reduce the content on the level that causes the game to crash, it no longer crashes. The same game did not crash before I upgraded the OS on those devices to 4.4.2. There's definitely a RAM usage issue with 4.4.2 OS on Android.
     
  30. zzajac

    zzajac

    Joined:
    Feb 20, 2015
    Posts:
    22
    @Rajmahal: Android 4.4.2 uses more RAM. You should optimize your memory usage because only 25% Androids have 2GB or more and only few models (I think not more 1% ) has more than 2GB. If you want to release app in few mothns it should fit in 1GB.
     
  31. cgJames

    cgJames

    Joined:
    Dec 3, 2014
    Posts:
    30
    It's not fixed. Issue tracker shows the bug as active. It would be great to get some feedback from @Unity 3d.

    We need more votes to get it fixed so if you have any weird crashes or unexplained behaviour on Android, this bug could be affecting you so head over to issues tracker and up vote it.
     
  32. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,051
    The difference is huge though in 4.4.2. The same game runs fine on an iPhone with 1GB of Ram but crashes on a Note 3 with 2 GB of RAM. For me to get it working I have had to compress textures by half and remove more than half of the meshes in the scene. That doesn't seem right at all. I find it hard to believe that 4.4.2 really uses that much extra RAM by design.
     
    MrEsquire likes this.
  33. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    993

    Thanks. I up voted it!
     
  34. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    635
    A device could have 16GB of RAM, but that doesn't mean it's actually allocating that much for you game. Each device can set it's own limit for an app.

    Are you looking at that number?

    Have it show you SystemInfo.graphicsMemorySize for each device to see how much RAM you are actually getting.
     
  35. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,051
    I can certainly do that. I currently have code that uses SystemInfo.MemorySize to assign values for quality settings and texture compression. However, what I'm saying is that before I updated my Note 3 to 4.4.2, it was able to run my game at full specs. Now that I updated Android to Kit Kat on that same device ... it is not able to run the same game code. This seems like either a bug in Unity or an issue with Kit Kat.

    Essentially, my game on my 2GB Note 3 now has to run under the same constraints as I have for my iPhone 4S (512MB of RAM) to work ... whereas it was working on full graphics mode before Kit Kat. It seems crazy to think that I have to put my Note 3 on the same graphics mode as my iPhone 4S just because of an Android OS update?

    If others are facing crashes on Kit Kat, it may likely be due to this new memory constraint. I'm seeing it just on the Samsung devices I use for testing ... but I'm sure it would be the same for released games.
     
    MrEsquire likes this.
  36. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    461
    This is a long shot, but what texture format are you using? If you use an unsupported texture format for the target device, Unity will convert the textures true colour, with significantly increased memory consumption.
     
  37. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,051
    Seriously? That's really crazy .... and would definitely explain it. I had it set to Automatic, which was what I had always set to before. I think I tried ETC as well when I was trouble shooting. Any idea what the correct format is for Samsung devices?

    Still doesn't explain why it was fine throughout the process before I upgraded to Kit Kat. The same devices (S4 and Note 3) had no issues with my game on high detail setting before Kit Kat.
     
  38. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    461
    Depends on the device. Everything supports ETC/RGBA16 and all OpenGL ES 3.0+ devices support ETC2. If ETC/RGBA16 fills your quality and build size needs, then it is the safest bet in any case. If not, that's what multiple APK deployments are for.

    Well, in itself it doesn't but if anything is pushing you close to the memory limit and Kit Kat uses more memory for itself, it could explain it. As I said, it's a long shot but worth a try nevertheless.
     
  39. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,051
    Yeah, I think I tried ETC RGB 16 when I was trouble shooting so I don't think that's the issue.
     
  40. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    635
    Are you using this in your manifest?

    android:largeHeap="true"
     
  41. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,051
    Not sure ... will check. What does that flag do?
     
  42. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    635
    For example, look at this page: https://developer.amazon.com/appsan...-feature-specifications#Device Specifications

    See the difference between heap size default/large? If you do largeHeap="true" it will give you the larger heap.

    That's what I was saying about you having memory issues with two different devices with the same amount of RAM, etc. You have no idea how much RAM you are actually being allocated unless you check. Each device has a different amount of RAM it will allocate you by default and also if you ask for the large heap.
     
  43. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,051
    Thanks for the tip. Is there a way to set the heap size with code within Unity? I'm not too familiar with how to change the manifest file ... I think it's in the apk when you unzip it, right? Is there a particular editor I should as using notepad wasn't very effective.
     
  44. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,051
    Just a quick update, upgrading to Unity 5 has fixed the memory problem. So I guess it was an issue with Unity. Let's hope they don't migrate the issue to Unity 5 at some point in the future. :rolleyes:
     
  45. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Good to know but hows the FPS in Unity 5 on Android, some people report lower performance?
     
  46. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,051
    I haven't noticed a difference personally ... but I haven't yet done extensive testing. Still working on redoing all the lightmapping and switching to the standard shader.
     
  47. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    635
    Basically you put your "custom" manifest in a specials android plugins folder and it will use it. Be sure to do some research and check it out if you feel like you want to do some stuff with it in the future.
     
  48. cgJames

    cgJames

    Joined:
    Dec 3, 2014
    Posts:
    30
    Getting this thread back on topic for those coming here looking for "2-5x increase in crashes from Samsung devices ... "

    Unity has acknowledged a bug where seemingly random blocks of code can be executed. It seems to affect Kitkat devices with Snapdragon 800s: Samsung Galaxy S5, HTC One M8, Nexus 5 ... most flagship devices.

    The bug is logged in issue tracker and getting it fixed will stop a lot of random crashes on flagship devices running Kitkat. The fix schedule is unknown so please head over to issue tracker and up vote it.
     
  49. florianpenzkofer

    florianpenzkofer

    Unity Technologies

    Joined:
    Sep 2, 2014
    Posts:
    183
    I was looking at issue 655263 before GDC and I was able to reproduce it on a Samsung Galaxy S5 (SM-G900F).
    It crashed in the JITed code when making a vcall, looked like use-after-free.
    I was not able to repro the crash when I did anything of: disabling GC, recompiling the DLLs, moving the scripts into the Unity project, disabling texture uploads at the API level, using mono without VFP support.
    Now I cannot reproduce it anymore, same software, same device :(. Very odd.
     
  50. zzajac

    zzajac

    Joined:
    Feb 20, 2015
    Posts:
    22
    @florianpenzkofer
    It occurs on our samsung devices when game is run first time. (corupted stacktraces or/and crash). When run game is run second time everyhink is ok. Sorry but uploding our project is very complicated because of building porocess and dependence of assetbundles, version control system). We coudln't reproduce it on small project.

    Also switching options in PlayerSettings(dynamicBatching, openGl version setting) changing behaviorur. On some devices it stop crashing(Snapdragon 801).