vcl/skia/gdiimpl.cxx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
New commits: commit 14e49062012f8699125422cc8a82a22b26f43143 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Mon Jan 1 17:47:11 2024 +0600 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Tue Jan 2 05:56:39 2024 +0100 tdf#158945: blind fix (try to decrease pending operations limit) *If* the crash in the bug was caused by OOM in Vulkan, then *maybe* it was exactly the case mentioned in the comment above: > queueing many tiny bitmaps ... may make [Skia] even run out of memory Let's try to reduce the threshold dynamically, from 1000 down, in the hope that this would avoid the OOM in the specific HW. If it doesn't, it will eventually still abort(). Change-Id: If6151d4f273a5f938030121d13c268bc9906fa23 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161516 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index e03fa32c3532..bc29920f1626 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -462,7 +462,8 @@ void SkiaSalGraphicsImpl::postDraw() // a problematic operation has been performed too many times without a flush. // Note that the counter is a static variable, as all drawing shares the same Skia drawing // context (and so the flush here will also flush all drawing). - if (pendingOperationsToFlush > 1000) + static int maxOperationsToFlush = 1000; + if (pendingOperationsToFlush > maxOperationsToFlush) { mSurface->flushAndSubmit(); pendingOperationsToFlush = 0; @@ -471,13 +472,20 @@ void SkiaSalGraphicsImpl::postDraw() // If there's a problem with the GPU context, abort. if (GrDirectContext* context = GrAsDirectContext(mSurface->getCanvas()->recordingContext())) { - // Running out of memory on the GPU technically could be possibly recoverable, - // but we don't know the exact status of the surface (and what has or has not been drawn to it), - // so in practice this is unrecoverable without possible data loss. + // We don't know the exact status of the surface (and what has or has not been drawn to it). + // But let's pretend it was drawn OK, and reduce the flush limit, to try to avoid possible + // small HW memory limitation if (context->oomed()) { - SAL_WARN("vcl.skia", "GPU context has run out of memory, aborting."); - abort(); + if (maxOperationsToFlush > 10) + { + maxOperationsToFlush /= 2; + } + else + { + SAL_WARN("vcl.skia", "GPU context has run out of memory, aborting."); + abort(); + } } // Unrecoverable problem. if (context->abandoned())