vcl/skia/gdiimpl.cxx |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

New commits:
commit 795b30b69a3b623837645f2b14d318e09c6bd210
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Tue Sep 22 17:31:10 2020 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Wed Sep 23 08:58:27 2020 +0200

    abort if Skia code detects problems with Vulkan
    
    The document from tdf#136244 in low memory conditions (32bit Windows)
    may be sometimes rendered without the alpha channel, i.e. Skia/Vulkan
    apparently render just the data bitmap but not the alpha bitmap.
    So check the status of the GPU context and abort if there's a problem.
    I've considered trying to recover by switching to Raster, but
    e.g. in this specific case something has already been drawn and it
    can't be done. Another problem in this specific case is that the whole
    app is running low on memory and copying the data from the GPU would
    fail anyway. So just fail hard to avoid silent data loss.
    
    Change-Id: If05f9c65b160ad5e7b9407b9f809606a1392d740
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103206
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 698d20730751..7722a8018619 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -399,6 +399,24 @@ void SkiaSalGraphicsImpl::postDraw()
         mPendingOperationsToFlush = 0;
     }
     SkiaZone::leave(); // matched in preDraw()
+    // If there's a problem with the GPU context, abort.
+    if (GrContext* context = mSurface->getCanvas()->getGrContext())
+    {
+        // 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.
+        if (context->oomed())
+        {
+            SAL_WARN("vcl.skia", "GPU context has run out of memory, 
aborting.");
+            abort();
+        }
+        // Unrecoverable problem.
+        if (context->abandoned())
+        {
+            SAL_WARN("vcl.skia", "GPU context has been abandoned, aborting.");
+            abort();
+        }
+    }
 }
 
 void SkiaSalGraphicsImpl::scheduleFlush()
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to