Author Topic: Crash (native)  (Read 12797 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12061
    • View Profile
    • http://www.jpct.net
Re: Crash (native)
« Reply #75 on: January 28, 2020, 10:15:42 am »
That's the one (or at least very similar) that I'm seeing for my own apps every now and then. But it doesn't really help. All the engine is doing, is to tell the GL driver to draw some geometry. Why this causes a crash deep inside of the GL pipeline under some circumstances is beyond me. Another problem is, that you can't be sure when this happen because there's no context. You don't know if this happens during normal operation (I've never ever experienced this on one of my own devices) or if it happens when the context is shutting down anyway (or doing some other wierd thing).

Offline AeroShark333

  • long
  • ***
  • Posts: 218
    • View Profile
Re: Crash (native)
« Reply #76 on: March 10, 2020, 03:04:25 am »
I actually do have an emulator on my PC where I can reproduce this SIGSEGV error.
However, I'm not sure if the emulator crash truly is identical to the crashes that users receive.

In Android Studio, I've been using the debug option to test some things out.
I'd let the application stop once it hits  the following line :
Code: [Select]
gl11.glDrawElements(this.primitiveType, this.indexCount, 5123, 0);
It's not running the above line yet until I tell it to continue, the app basically hangs/suspends in meantime.
While the app is suspended, I can run an evaluation (custom code) that I can insert through the debugger as follows:
Code: [Select]
for(int xxx=3;xxx<this.indexCount;xxx+=3){
System.out.println("Indexcount=" + xxx);
gl11.glDrawElements(this.primitiveType, xxx, 5123, 0);
}

Now there are three different scenario's:
- The application crashes when a certain index count (xxx) has been reached. (lower limit)
- The application crashes for another index count (xxx+6). (higher limit)
- The application doesn't crash at all (because it does still happen randomly...)

So for an Object3D, there's always two values as index count where it could crash: xxx and xxx+6.

The only thing that changes this xxx value (and xxx+6 value) is:
- the vertex count of the object
- the overall structure of the object.

I have only tested this with UV-spheres and ico-spheres.

As a conclusion, I have found that if it was possible to lower these 'index counts', so that high values are not reached, the crash won't happen.
The only way to achieve that is to lower the Config.glBatchSize value.
And yes, with the emulator this does help to reduce the occurences of this SIGSEGV crash to 0.
I'm not sure if this will fix the issue for real devices but it's worth a shot I guess.

I have two questions remaining, however:
- Why is the default Config.glBatchSize = 8000?
- If an Object3D for instance has 48000 vertices and the Config.glBatchSize = 8000. The Object3D loads it in batches of 23997, 24000 and 3 vertices. Why is the first batch 3 vertices smaller than the batch size would suggest?


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12061
    • View Profile
    • http://www.jpct.net
Re: Crash (native)
« Reply #77 on: March 10, 2020, 02:52:22 pm »
The 8000 is just a magic number. I had some trouble with higher values on the desktop using older nVidia drivers, so I tried to find a compromise between these problems and a reasonable high value. It then transfered over to the Android version. It might indeed help to lower it for some unknown reason.

About the strange batch sizes...I don't know ATM. I'll have a look at this.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12061
    • View Profile
    • http://www.jpct.net
Re: Crash (native)
« Reply #78 on: March 10, 2020, 09:26:07 pm »
A had a look at the batch size issue. It's a problem with the way in which batch sizes are calculated. It's only really obvious if the vertex count is a multiple of the batch size. I've fixed it, but I don't think that it requires a new version just for that. It looks strange in the log output, but it's not an actual problem.

Offline AeroShark333

  • long
  • ***
  • Posts: 218
    • View Profile
Re: Crash (native)
« Reply #79 on: March 11, 2020, 12:53:21 am »
Alright, thank you. I figured it'd not make a big difference but I mostly wondered if this was intentional so I guess not.

About the ideal batch size, I have found Config.glBatchSize=3000 to be pretty ideal in my use cases when the vertex count for the Object3D is smaller than about 100000. The Config.glBatchSize needs to be further decreased when your Object3D has higher vertexcount. But this different per Object3D structure again...

In my use case the distance between vertices does become smaller for higher vertexcount... I don't know if that could be a problem that the vertices become more dense. I have noticed a stronger drop for the needed glBatchSize for higher polygoncount UV-spheres than for higher polygoncount ico-spheres.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12061
    • View Profile
    • http://www.jpct.net
Re: Crash (native)
« Reply #80 on: March 11, 2020, 08:41:26 am »
Honestly, I've no idea about how and why the vertex count can cause an issue. As mentioned, I had some similar experience on the desktop and I debugged the hell out of it, thinking that my counts were somehow wrong and that I was rendering some out of bounds geometry. But that's not the case, so I really don't know what the issue is here...