Skip to content

Commit 5db399a

Browse files
committed
fix: track shader cache key invalidation
1 parent f65832a commit 5db399a

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

packages/oxlint-plugin-react-doctor/src/plugin/rules/r3f/three-on-before-compile-require-program-cache-key.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ describe("three-on-before-compile-require-program-cache-key", () => {
6969
material.onBeforeCompile = shader => {
7070
if (mode === "warm") shader.fragmentShader += " ";
7171
};`,
72+
`import { MeshStandardMaterial } from "three";
73+
let mode = "warm";
74+
const material = new MeshStandardMaterial({
75+
customProgramCacheKey: () => mode,
76+
onBeforeCompile: shader => {
77+
if (mode === "warm") shader.fragmentShader += " ";
78+
},
79+
});
80+
material.customProgramCacheKey = null;`,
7281
])("reports mutable program variants without a cache key", (code) => {
7382
expect(runRule(threeOnBeforeCompileRequireProgramCacheKey, code).diagnostics).toHaveLength(1);
7483
});

packages/oxlint-plugin-react-doctor/src/plugin/rules/r3f/three-on-before-compile-require-program-cache-key.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ export const threeOnBeforeCompileRequireProgramCacheKey = defineRule({
335335
"Program:exit"() {
336336
for (const candidate of candidates) {
337337
if (
338-
candidate.hasConstructorCacheKey ||
338+
(candidate.materialSymbolId === null && candidate.hasConstructorCacheKey) ||
339339
(candidate.materialSymbolId !== null &&
340340
materialSymbolsWithCacheKeys.has(candidate.materialSymbolId))
341341
) {

0 commit comments

Comments
 (0)