javascript - 无法读取 null 的属性“requestDevice”
问题描述
我试图在 WebGpu 中渲染 Web GPU 着色器对象
它返回此错误
未捕获(承诺中)类型错误:无法在 cube.html:28 处读取 null 的属性“requestDevice”
这是我的 requestDevice 代码
(async () => {
const [adapter, glslang] = await Promise.all([
navigator.gpu.requestAdapter(),
import("https://unpkg.com/@webgpu/glslang@0.0.7/web/glslang.js").then(m => m.default())
]);
const device = await adapter.requestDevice();
const canvas = document.getElementById("webgpu-canvas");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
});
任何想法来解决这个错误?
解决方案
在尝试了很多事情之后,我通过在 about:flags 中重新启用 --enable-unsafe-webgpu 标志来修复它!
刷新页面之前工作了几次,但后来停止了......现在似乎很好!
推荐阅读
- ios - 是否可以同时在多个模拟器设备上进行 iOS XCUITesting?
- javascript - React 将数组从父状态传递到子状态
- c# - 如果已经登录,使用会话状态将用户重定向到主页
- c++ - 在字符串中的偶数位置提取字母?
- html - 如何创建包含带有 R 的图像的 html 表(通过相对路径或插入 - base64)?
- node.js - 如何将多个项目同时插入到 MongoDB 集合中?
- tableau-api - 列聚合上的 Tableau 堆叠和并排条形图
- html - LinearGradiant SVG 动画在 Firefox 中看起来不正确
- dynamics-crm - 未考虑 FetchXml 查询的条件
- javascript - 邮政编码的openweathermap天气数据不起作用?