[Huawei P8 ROMs, Kernels, Recoveries, & Other Devel] nexolight:
[MENTION=7539994]GodzillaMonster[/MENTION]

I don't know if the call stack is different on success - It only fails under this circumstances.

But according to the CBZ (branch past that loop if x0 is zero) it should not enter that loop where the SEGV is with surfaceDamage.numRects set to 0 right?

But exactly that is the case at the first time where surfaceDamage.numRects is 0 and visibleRegionScreen.numRects is 1

It's the last information before prepare() in HWC is called.

There are multiple SEGV's it's not that easy to debug since it differs between:

ANR in systemui and not showing any SEGV at all while just freezing the screen until it's terminated. (we should fix that later)

The mentioned SEGV (most of the time)

Another SEGV which

only

occurs as soon as more as 2 layers are passed in prepare() (under the same circumstances like the first SEGV) The first SEGV may occur as well with more than 2 layers passed but not exclusively:

(The 2nd SEGV)

#00 pc 0000000000016644 /system/lib64/hw/hwcomposer.hi3635.so
02-24 20:24:32.532 2840 2840 F DEBUG : #01 pc 0000000000018b7c /system/lib64/hw/hwcomposer.hi3635.so (_ZN11HwcCompInfo20CalcOverlapLayersNumEv+292)
02-24 20:24:32.532 2840 2840 F DEBUG : #02 pc 0000000000016464 /system/lib64/hw/hwcomposer.hi3635.so
02-24 20:24:32.532 2840 2840 F DEBUG : #03 pc 000000000003cfdc /system/lib64/libsurfaceflinger.so
02-24 20:24:32.532 2840 2840 F DEBUG : #04 pc 000000000002f340 /system/lib64/libsurfaceflinger.so
02-24 20:24:32.532 2840 2840 F DEBUG : #05 pc 000000000002e5a8 /system/lib64/libsurfaceflinger.so
02-24 20:24:32.532 2840 2840 F DEBUG : #06 pc 000000000002e320 /system/lib64/libsurfaceflinger.so
02-24 20:24:32.532 2840 2840 F DEBUG : #07 pc 000000000001aeec /system/lib64/libutils.so (_ZN7android6Looper9pollInnerEi+312)
02-24 20:24:32.532 2840 2840 F DEBUG : #08 pc 000000000001b224 /system/lib64/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+80)
02-24 20:24:32.532 2840 2840 F DEBUG : #09 pc 000000000002a708 /system/lib64/libsurfaceflinger.so
02-24 20:24:32.532 2840 2840 F DEBUG : #10 pc 000000000002de14 /system/lib64/libsurfaceflinger.so (_ZN7android14SurfaceFlinger3runEv+20)
02-24 20:24:32.532 2840 2840 F DEBUG : #11 pc 0000000000001190 /system/bin/surfaceflinger
02-24 20:24:32.532 2840 2840 F DEBUG : #12 pc 000000000001bcd8 /system/lib64/libc.so (__libc_init+100)
02-24 20:24:32.532 2840 2840 F DEBUG : #13 pc 0000000000000fcc /system/bin/surfaceflinger

Some additional info to the 1st. SEGV - there's one error message before ---- crash:

02-24 20:42:59.335 2821 2821 E Region : Region::boolean_operation(op=7) invalid Rect={1,0,-1823200520,127}

The code which produces it is in frameworks/native/libs/ui/Region.cpp

void Region::boolean_operation(int op, Region& dst,
const Region& lhs,
const Rect& rhs, int dx, int dy)
{
[B] // We allow this particular flavor of invalid Rect, since it is used as a
// signal value in various parts of the system[/B]
if (!rhs.isValid() && rhs != Rect::INVALID_RECT) {
ALOGE("Region::boolean_operation(op=%d) invalid Rect={%d,%d,%d,%d}",
op, rhs.left, rhs.top, rhs.right, rhs.bottom);
return;
}

BTW: I patched that loop in assembly but that causes just the next completely different SEGV in another function later on (~ change layer format related).

I start to think about implementing the HWC by myself. I'm not sure how difficult that would be with a partial lack of essential c++ knowledge