From 25f013ba1b809e9f962dafbefaeb860512f386e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Thu, 18 May 2023 01:54:35 +0200 Subject: [PATCH] audio and browsers section for wasm examples (#8625) # Objective - Help users better understand audio issues in wasm ## Solution - Describe some of the known issues, and some of the workarounds --- docs-template/EXAMPLE_README.md.tpl | 9 +++++++++ examples/README.md | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/docs-template/EXAMPLE_README.md.tpl b/docs-template/EXAMPLE_README.md.tpl index 1a8d141372..e0a8eb091e 100644 --- a/docs-template/EXAMPLE_README.md.tpl +++ b/docs-template/EXAMPLE_README.md.tpl @@ -52,6 +52,9 @@ git checkout v0.4.0 - [WASM](#wasm) - [Setup](#setup-2) - [Build & Run](#build--run-2) + - [WebGL2 and WebGPU](#webgl2-and-webgpu) + - [Audio in the browsers](#audio-in-the-browsers) + - [Optimizing](#optimizing) - [Loading Assets](#loading-assets) # The Bare Minimum @@ -244,6 +247,12 @@ Bevy has an helper to build its examples: This helper will log the command used to build the examples. +### Audio in the browsers + +For the moment, everything is single threaded, this can lead to stuttering when playing audio in browsers. Not all browsers react the same way for all games, you will have to experiment for your game. + +In browsers, audio is not authorized to start without being triggered by an user interaction. This is to avoid multiple tabs all starting to auto play some sounds. You can find more context and explanation for this on [Google Chrome blog](https://developer.chrome.com/blog/web-audio-autoplay/). This page also describes a JS workaround to resume audio as soon as the user interact with your game. + ### Optimizing On the web, it's useful to reduce the size of the files that are distributed. diff --git a/examples/README.md b/examples/README.md index b1cac442fa..3e71181789 100644 --- a/examples/README.md +++ b/examples/README.md @@ -70,6 +70,9 @@ git checkout v0.4.0 - [WASM](#wasm) - [Setup](#setup-2) - [Build & Run](#build--run-2) + - [WebGL2 and WebGPU](#webgl2-and-webgpu) + - [Audio in the browsers](#audio-in-the-browsers) + - [Optimizing](#optimizing) - [Loading Assets](#loading-assets) # The Bare Minimum @@ -533,6 +536,12 @@ Bevy has an helper to build its examples: This helper will log the command used to build the examples. +### Audio in the browsers + +For the moment, everything is single threaded, this can lead to stuttering when playing audio in browsers. Not all browsers react the same way for all games, you will have to experiment for your game. + +In browsers, audio is not authorized to start without being triggered by an user interaction. This is to avoid multiple tabs all starting to auto play some sounds. You can find more context and explanation for this on [Google Chrome blog](https://developer.chrome.com/blog/web-audio-autoplay/). This page also describes a JS workaround to resume audio as soon as the user interact with your game. + ### Optimizing On the web, it's useful to reduce the size of the files that are distributed.