nss: upgrade to release 3.73
[LibreOffice.git] / vcl / skia / zone.cxx
blob34e3f80f8b7819b3212e2cea7574d6b9f1183a7a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <skia/zone.hxx>
12 #include <officecfg/Office/Common.hxx>
13 #include <com/sun/star/util/XFlushable.hpp>
14 #include <com/sun/star/configuration/theDefaultProvider.hpp>
16 #include <sal/log.hxx>
17 #include <o3tl/unreachable.hxx>
19 #include <vcl/skia/SkiaHelper.hxx>
21 #include <config_skia.h>
23 /**
24 * Called from a signal handler or watchdog thread if we get
25 * a crash or hang in some driver.
27 void SkiaZone::hardDisable()
29 // protect ourselves from double calling etc.
30 static bool bDisabled = false;
31 if (bDisabled)
32 return;
34 bDisabled = true;
36 // Instead of disabling Skia as a whole, only force the CPU-based
37 // raster mode, which should be safe as it does not use drivers.
38 std::shared_ptr<comphelper::ConfigurationChanges> xChanges(
39 comphelper::ConfigurationChanges::create());
40 officecfg::Office::Common::VCL::ForceSkiaRaster::set(true, xChanges);
41 xChanges->commit();
43 // Force synchronous config write
44 css::uno::Reference<css::util::XFlushable>(
45 css::configuration::theDefaultProvider::get(comphelper::getProcessComponentContext()),
46 css::uno::UNO_QUERY_THROW)
47 ->flush();
50 void SkiaZone::checkDebug(int nUnchanged, const CrashWatchdogTimingsValues& aTimingValues)
52 SAL_INFO("vcl.watchdog", "Skia watchdog - unchanged "
53 << nUnchanged << " enter count " << enterCount()
54 << " breakpoints mid: " << aTimingValues.mnDisableEntries
55 << " max " << aTimingValues.mnAbortAfter);
58 const CrashWatchdogTimingsValues& SkiaZone::getCrashWatchdogTimingsValues()
60 switch (SkiaHelper::renderMethodToUse())
62 case SkiaHelper::RenderVulkan:
64 #if defined(SK_RELEASE)
65 static const CrashWatchdogTimingsValues vulkanValues = { 6, 20 }; /* 1.5s, 5s */
66 #elif defined(SK_DEBUG)
67 static const CrashWatchdogTimingsValues vulkanValues = { 60, 200 }; /* 15s, 50s */
68 #else
69 #error Unknown Skia debug/release setting.
70 #endif
71 return vulkanValues;
73 case SkiaHelper::RenderRaster:
75 // CPU-based operations with large images may take a noticeably long time,
76 // so use large values. CPU-based rendering shouldn't use any unstable drivers anyway.
77 static const CrashWatchdogTimingsValues rasterValues = { 600, 2000 }; /* 150s, 500s */
78 return rasterValues;
81 O3TL_UNREACHABLE;
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */