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

@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 (Crash occurs in kitkat (under opengl 2.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:

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 7bf28700 Build fingerprint:
'Verizon/jfltevzw/jfltevzw:4.4.2/KOT49H/I545VRUFNC5:user/release-keys' Revision: '11' pid: 771, tid: 789,
name: UnityMain >>> com.MyOrgName.MyBundleId <<<
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

Crashed Thread:

java.lang.Error: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 849fb700
Build fingerprint: 'Verizon/jfltevzw/jfltevzw:4.4.2/KOT49H/I545VRUFNC5:user/release-keys'
Revision: '11'
pid: 5915, tid: 5932, name: UnityMain >>> com.MyOrgname.MyBundleId <<<
r0 849fb700 r1 781f3880 r2 000001c0 r3 00000000
r4 000001c0 r5 77954994 r6 849fb700 r7 781f3840
r8 000001c0 r9 00000001 sl 000001c0 fp 00000001
ip 00000006 sp 77954918 lr 7601710b pc 4009327e cpsr 0000000b
at libc.__memcpy_base(__memcpy_base:261)
\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?

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

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.

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.

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!

The bug is present again in Android 4.4.4 .

These devices are currently affected:

  • Sony Xperia Z1
  • Sony Xperia Z1 Compact
  • Sony Xperia Z Ultra

We use Unity 4.5.1p3 and NGUI 3.6.5.

+1 Same problem here with a 4.4.4 device

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

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.

This seems to be the exact issue I have been encountering as well. I tracked down the issue to this code

ShadowTag RegisterObject(int classId, IShadowable obj)
{
  ShadowTag tag = new ShadowTag(obj, classId, NULL_ID, 0);
  int objectId = m_objectList.Add(tag);
  tag.ObjectId = objectId;
  obj.SYS_Tag = tag;
  if (tag == null)
    throw new Exception1();
  if (obj.SYS_Tag == null)
    throw new Exception2();
  return tag;
}

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.

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

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.

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?

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.

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

I suggest everyone upgrade to 4.6.2 unity and retest.

4.6.2 nothing changes it looks like Snapdragon 800-801+ Android 4.4 is the problem (Galaxy S5, LG G3, HTC One M8)

switching to OpenGL 3.0 or Automatic can also solve this problem

http://forum.unity3d.com/threads/regression-null-reference-crash-player-on-android-5-0-again.295359/

:-/

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.