{"record":{"id":"42fa7bc4ec10fcd0","repo":"stride3d/stride","slug":"shader-compilation-is-not-allowed-at-run-time-on-this","errorCode":null,"errorMessage":"Shader Compilation is not allowed at run time on this platform.","messagePattern":"Shader Compilation is not allowed at run time on this platform\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"critical","filePath":"sources/shaders/Stride.Shaders.Effects/Compiler/NullEffectCompiler.cs","lineNumber":34,"sourceCode":"        public NullEffectCompiler(IVirtualFileProvider fileProvider, DatabaseFileProvider database)\n        {\n            FileProvider = fileProvider;\n            this.database = database;\n        }\n\n        public override ObjectId GetShaderSourceHash(string type)\n        {\n            var url = GetStoragePathFromShaderType(type);\n            var shaderSourceId = ObjectId.Empty;\n            database?.ContentIndexMap.TryGetValue(url, out shaderSourceId);\n            return shaderSourceId;\n        }\n\n        public override IVirtualFileProvider FileProvider { get; set; }\n\n        public override TaskOrResult<EffectBytecodeCompilerResult> Compile(ShaderMixinSource mixinTree, EffectCompilerParameters effectParameters, CompilerParameters compilerParameters, ObjectId effectInputHash)\n        {\n            throw new NotSupportedException(\"Shader Compilation is not allowed at run time on this platform.\");\n        }\n    }\n}\n","sourceCodeStart":16,"sourceCodeEnd":38,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Effects/Compiler/NullEffectCompiler.cs#L16-L38","documentation":"NullEffectCompiler is a placeholder compiler used on platforms that forbid runtime shader compilation. Its Compile always throws NotSupportedException: all effects must have been precompiled at build time and loaded from the bytecode cache instead.","triggerScenarios":"Any call path reaching NullEffectCompiler.Compile at runtime — requesting an effect whose bytecode is not in the cache on a runtime-only platform (consoles, some mobile targets), or accidentally wiring NullEffectCompiler in an editor/tool context.","commonSituations":"Deploying without the precompiled effects database; new shader permutations added after the build-time effect compile; misconfigured compiler factory selecting the null compiler during development.","solutions":["Precompile all effect permutations at build time (Stride Game Studio effect compilation) and ship the bytecode cache.","Ensure the runtime file provider is mounted on the compiled-effects database so the cache resolves bytecode before hitting the null compiler.","Use a real compiler (EffectCompiler/EffectCompilerCache) in editor/tooling scenarios.","Remove or statically declare dynamically generated shader permutations so they get precompiled."],"exampleFix":"// before\nvar compiler = new NullEffectCompiler(); // then compiler.Compile(mixin, ...) throws\n// after (build-time)\nvar compiler = new EffectCompilerCache(new EffectCompiler(fileProvider), databaseFileProvider);\n// runtime: load precompiled bytecode instead of compiling","handlingStrategy":"fallback","validationCode":"if (compiler is NullEffectCompiler) throw new InvalidOperationException(\"Runtime shader compilation unavailable; ensure effects were precompiled and the bytecode cache is mounted\");","typeGuard":"bool IsRuntimeNullCompiler(EffectCompilerBase c) => c is NullEffectCompiler;","tryCatchPattern":"try { bytecode = compiler.Compile(mixin, parameters, compilerParameters, hash); } catch (NotSupportedException ex) when (ex.Message.Contains(\"not allowed at run time\")) { /* load precompiled bytecode from cache or fail deployment check */ }","preventionTips":["Precompile all effect permutations in the build pipeline","Mount the compiled-effects database at startup on runtime-only platforms","Never use NullEffectCompiler in editor/tool scenarios","Add a deployment smoke test that loads every effect"],"tags":["unsupported-operation","shaders","runtime","platform"],"backgroundTag":"operation-not-supported","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}