Skip to content

Commit 0b847b0

Browse files
authored
fix: broken shader cache due to compilation error (electron#40450)
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4988290
1 parent a77f2e0 commit 0b847b0

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

patches/chromium/.patches

+1
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,4 @@ revert_remove_the_allowaggressivethrottlingwithwebsocket_feature.patch
136136
fix_handle_no_top_level_aura_window_in_webcontentsimpl.patch
137137
feat_allow_passing_of_objecttemplate_to_objecttemplatebuilder.patch
138138
chore_remove_check_is_test_on_script_injection_tracker.patch
139+
crash_gpu_process_and_clear_shader_cache_when_skia_reports.patch
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Le Hoang Quyen <[email protected]>
3+
Date: Tue, 31 Oct 2023 08:52:25 +0000
4+
Subject: Crash GPU process and clear shader cache when skia reports
5+
compileError.
6+
7+
Sometimes Skia failed to compile the cached GLSL because the driver had
8+
been changed but GL_RENDERER was still the same. In this case, we better
9+
crash the GPU process and signal the browser to clear the cache & let
10+
Skia regenerate the GLSL in the next run.
11+
12+
Even if the compile failure wasn't caused by the cached GLSL. It's still
13+
better to crash the GPU process and let the shaders be re-generated.
14+
Because a failed compilation would have resulted in wrong rendering
15+
even if we had allowed the process to continue its execution.
16+
17+
Bug: 1442633
18+
Change-Id: Ia0e36bd4674877de5be451a6ea9c4e7fa5e34e8e
19+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4988290
20+
Reviewed-by: Sunny Sachanandani <[email protected]>
21+
Commit-Queue: Quyen Le <[email protected]>
22+
Cr-Commit-Position: refs/heads/main@{#1217461}
23+
24+
diff --git a/gpu/command_buffer/service/shared_context_state.cc b/gpu/command_buffer/service/shared_context_state.cc
25+
index 63f6c33ad5f41cde0fca08d60e7e10fe1154e165..f422ec52ca74f5a636e11591ba42444773a5c682 100644
26+
--- a/gpu/command_buffer/service/shared_context_state.cc
27+
+++ b/gpu/command_buffer/service/shared_context_state.cc
28+
@@ -4,6 +4,7 @@
29+
30+
#include "gpu/command_buffer/service/shared_context_state.h"
31+
32+
+#include "base/immediate_crash.h"
33+
#include "base/observer_list.h"
34+
#include "base/strings/stringprintf.h"
35+
#include "base/system/sys_info.h"
36+
@@ -101,6 +102,13 @@ void SharedContextState::compileError(const char* shader, const char* errors) {
37+
<< "------------------------\n"
38+
<< shader << "\nErrors:\n"
39+
<< errors;
40+
+
41+
+ // Increase shader cache shm count and crash the GPU process so that the
42+
+ // browser process would clear the cache.
43+
+ GpuProcessShmCount::ScopedIncrement increment(
44+
+ use_shader_cache_shm_count_.get());
45+
+
46+
+ base::ImmediateCrash();
47+
}
48+
}
49+
50+
@@ -305,6 +313,7 @@ bool SharedContextState::InitializeGanesh(
51+
gl::ProgressReporter* progress_reporter) {
52+
progress_reporter_ = progress_reporter;
53+
gr_shader_cache_ = cache;
54+
+ use_shader_cache_shm_count_ = use_shader_cache_shm_count;
55+
56+
size_t max_resource_cache_bytes;
57+
size_t glyph_cache_max_texture_bytes;
58+
diff --git a/gpu/command_buffer/service/shared_context_state.h b/gpu/command_buffer/service/shared_context_state.h
59+
index 05822df27221cd5003e8c12f809805f3bd0c597b..7c21a81066afd77e310f0fdfca7da92f8f7cb4e1 100644
60+
--- a/gpu/command_buffer/service/shared_context_state.h
61+
+++ b/gpu/command_buffer/service/shared_context_state.h
62+
@@ -392,6 +392,8 @@ class GPU_GLES2_EXPORT SharedContextState
63+
std::vector<uint8_t> scratch_deserialization_buffer_;
64+
raw_ptr<gpu::raster::GrShaderCache, DanglingUntriaged> gr_shader_cache_ =
65+
nullptr;
66+
+ raw_ptr<GpuProcessShmCount, DanglingUntriaged> use_shader_cache_shm_count_ =
67+
+ nullptr;
68+
69+
// |need_context_state_reset| is set whenever Skia may have altered the
70+
// driver's GL state.

0 commit comments

Comments
 (0)