--- title: WebGLSync slug: Web/API/WebGLSync translation_of: Web/API/WebGLSync --- <div>{{APIRef("WebGL")}} {{SeeCompatTable}}</div> <p>The <strong><code>WebGLSync</code></strong> interface is part of the <a href="/en-US/docs/Web/API/WebGL_API">WebGL 2</a> API and is used to synchronize activities between the GPU and the application.</p> <p>When working with <code>WebGLSync</code> objects, the following methods of the {{domxref("WebGL2RenderingContext")}} are useful:</p> <ul> <li>{{domxref("WebGL2RenderingContext.fenceSync()")}}</li> <li>{{domxref("WebGL2RenderingContext.deleteSync()")}}</li> <li>{{domxref("WebGL2RenderingContext.isSync()")}}</li> <li>{{domxref("WebGL2RenderingContext.clientWaitSync()")}}</li> <li>{{domxref("WebGL2RenderingContext.waitSync()")}}</li> <li>{{domxref("WebGL2RenderingContext.getSyncParameter()")}}</li> </ul> <h2 id="示例">示例</h2> <h3 id="创建一个WebGLSync对象">创建一个WebGLSync对象</h3> <p>in this example, <code>gl</code> must be a {{domxref("WebGL2RenderingContext")}}. <code>WebGLSync</code> objects are not available in WebGL 1.</p> <pre class="brush: js">var sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);</pre> <h2 id="Specifications">Specifications</h2> <table class="standard-table"> <tbody> <tr> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> <tr> <td>{{SpecName('WebGL2', "#3.4", "WebGLSync")}}</td> <td>{{Spec2('WebGL2')}}</td> <td>Initial definition.</td> </tr> </tbody> </table> <h2 id="浏览器兼容性">浏览器兼容性</h2> <p>{{Compat("api.WebGLSync.WebGLSync")}}</p> <h2 id="相关链接">相关链接</h2> <ul> <li>{{domxref("WebGLRenderingContext.finish()")}}</li> </ul>