From: Twaik Yont <9674930+twaik@users.noreply.github.com> Rendering could occasionally stall or hit: ``` err:system:user_check_not_lock BUG: holding USER lock ``` The issue was difficult to reproduce consistently and often disappeared when adding `TRACE` statements, suggesting a race or memory ordering problem. Inserting a full memory barrier (`__sync_synchronize()`) in `dequeueBuffer_DEPRECATED()` makes the problem reliably disappear in the tested setup. The exact root cause is still unclear (possible interaction between Wine changes, toolchain/code generation, or Android 7.1.x behavior). For now, treat this as a workaround to enforce proper memory ordering and avoid the USER lock assertion. Additionally, handle the case where `dequeueBuffer_DEPRECATED()` reports success but returns a NULL buffer, and bail out early instead of passing it to `gralloc_lock()`. Signed-off-by: Twaik Yont <9674930+twaik@users.noreply.github.com> --- dlls/wineandroid.drv/device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dlls/wineandroid.drv/device.c b/dlls/wineandroid.drv/device.c index 48da18dc65c..bd82b07703d 100644 --- a/dlls/wineandroid.drv/device.c +++ b/dlls/wineandroid.drv/device.c @@ -1351,6 +1351,7 @@ static int queueBuffer( struct ANativeWindow *window, struct ANativeWindowBuffer static int dequeueBuffer_DEPRECATED( struct ANativeWindow *window, struct ANativeWindowBuffer **buffer ) { int fence, ret = dequeueBuffer( window, buffer, &fence ); + __sync_synchronize(); if (!ret) wait_fence_and_close( fence ); return ret; @@ -1474,6 +1475,7 @@ static int perform( ANativeWindow *window, int operation, ... ) int ret = window->dequeueBuffer_DEPRECATED( window, &buffer ); if (!ret) { + if (!buffer) return 0x1; if ((ret = gralloc_lock( buffer, &buffer_ret->bits ))) { WARN( "gralloc->lock %p failed %d %s\n", win->hwnd, ret, strerror(-ret) ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9874