You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Chrome v103+出现WebAssembly编译错误,Rust Wasm开发扩展求助

解决Chrome扩展中Wasm代码生成被禁止的问题

Chrome v102及以上版本收紧了扩展内WebAssembly的运行权限,默认限制Wasm代码生成,这就是你遇到CompileError: WebAssembly.instantiateStreaming(): Wasm code generation disallowed by embedder错误的原因。

以下是具体解决方案:

  • 修改扩展的manifest.json,根据Manifest版本添加对应权限:

    • 若使用Manifest V3,在content_security_policy的extension_pages中加入'wasm-unsafe-eval':
      {
        "manifest_version": 3,
        "content_security_policy": {
          "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self';"
        },
        // 其他扩展配置项
      }
      
    • 若使用Manifest V2,直接调整content_security_policy字段:
      {
        "manifest_version": 2,
        "content_security_policy": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self';",
        // 其他扩展配置项
      }
      
  • 保持Wasm文件的合规加载:不要用eval或动态生成Wasm代码的方式,继续使用WebAssembly.instantiateStreaming直接加载本地Wasm文件,避免跨域加载。

  • 重新加载扩展并测试:修改配置后,在Chrome扩展管理页面重新加载扩展,验证v103+版本下Wasm是否正常运行。

内容的提问来源于stack exchange,提问作者Feelix343

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 19:15:12