summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-09-22 17:31:10 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-09-23 08:58:27 +0200
commit795b30b69a3b623837645f2b14d318e09c6bd210 (patch)
tree7a927921796711e2937d9f01c768f34363a64c2a /vcl
parent797315f220f82682748efaf80a29844a93f04f48 (diff)
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.lunak@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/skia/gdiimpl.cxx18
1 files changed, 18 insertions, 0 deletions
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()