Skip to content

Instantly share code, notes, and snippets.

@bczhc
Created February 10, 2026 05:35
Show Gist options
  • Select an option

  • Save bczhc/12d2656d5463c4bba75944679af4fc6f to your computer and use it in GitHub Desktop.

Select an option

Save bczhc/12d2656d5463c4bba75944679af4fc6f to your computer and use it in GitHub Desktop.
Android手机上运行WebGPU

目前Android手机上只有Chrome/Android WebView支持WebGPU。但实际发现,WebGPU只对 https://webgpu.github.io/webgpu-samples/sample/helloTriangle 官方示例有用,访问其他地址的网页时,navigator.gpuundefined

注意到上面的官方示例中有这几行:

<!-- WebGPUCompatibilityMode origin token for https://webgpu.github.io expiring April 21, 2026 -->
    <meta
      http-equiv="origin-trial"
      content="Aktu7041jFm00ls336/bRinubASRzg1tPs4wxXOZkF1uP0LaIURinGC7ti0Vf352Q9OKFL1siRfpptLjNIKpKQcAAABheyJvcmlnaW4iOiJodHRwczovL3dlYmdwdS5naXRodWIuaW86NDQzIiwiZmVhdHVyZSI6IldlYkdQVUNvbXBhdGliaWxpdHlNb2RlIiwiZXhwaXJ5IjoxNzc2NzI5NjAwfQ=="
    />
    <!-- WebGPUCompatibilityMode origin token for http://localhost:8080 expiring April 21, 2026 -->
    <meta
      http-equiv="origin-trial"
      content="AqW27Ayelg5vbcAaYcweU+sLjZq5r6idHCWU4MJgnkP1YBgmOMqazdGuakSnGylTkyA/bRHkCJZFdfYjFlylOgAAAABaeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwODAiLCJmZWF0dXJlIjoiV2ViR1BVQ29tcGF0aWJpbGl0eU1vZGUiLCJleHBpcnkiOjE3NzY3Mjk2MDB9"
    />

https://developer.chrome.com/origintrials/#/view_trial/1489002626799370241

似乎兼容模式(以OpenGL ES运行)是半开放模式。可以从上述网站申请令牌。不过测试发现对本地localhost是豁免的,所以,在手机上把网站运行在localhost即可启用WebGPU。使用Termux中的ssh实现转发电脑Vite服务器到手机本地。

ssh -vNCL 8080:localhost:5173 username@ip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment