1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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>
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;
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
);
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
)
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 */
69 #error Unknown Skia debug/release setting.
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 */
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */