Use Canvas fallback when WebGL is unavailable

This commit is contained in:
waozi committed 2026-08-19 19:25:44 -03:00
1 parent 72736b010f
commit 9458c1e4b2
4 files changed
+20 -14

No files matched your search

+12 -11
View File
@@ -449,6 +449,14 @@ WEB_TARGET := $(WEB_DIST_DIR)/index.html
WEB_APP_SCRIPT := <script>window.__inbeLoadApp("index.js?v=$(WEB_CACHE_BUSTER)")</script>
WEB_JS_TARGET := $(WEB_DIST_DIR)/index.js
WEB_BOOT_JS := src/web_boot.js
# Canvas-backend web build: kryon's HTML5 Canvas2D Tier A backend instead of
# raylib+GLFW — no libraylib.web.a, no WebGL. Sync-account crypto (liboqs)
# and audio are not carried in this target: scripts/ksync-canvas-shim.c
# reports sync unavailable and kryon's canvas audio is null-grade.
WEB_CANVAS_DIR := $(BUILD_DIST_DIR)/web-canvas
WEB_CANVAS_TARGET := $(WEB_CANVAS_DIR)/index.html
KRYON_CANVAS_SRCS := $(filter-out $(KRYON_DIR)/src/ksync/% $(KRYON_RAYLIB_WRAPPERS_C),$(KRYON_SRCS))
KSYNC_CANVAS_SHIM := scripts/ksync-canvas-shim.c
WEB_DIST_ZIP := $(BUILD_DIST_DIR)/$(APP_NAME)-web.zip
WEB_SMOKE_BROWSER ?= auto
WEB_SMOKE_TEST := scripts/web-smoke-test.mjs
@@ -1285,27 +1293,20 @@ $(WEB_JS_TARGET): Makefile $(WEB_SRC) $(KRYON_WEB_SRCS) $(KRYON_ICON_STAMP) $(SQ
-lidbfs.js \
-lm
$(WEB_TARGET): src/web_shell.html $(WEB_BOOT_JS) $(WEB_JS_TARGET) vendor/kryon/web/kryon-web-present.js manifest.json $(WEB_ASSET_FILES) $(MEDITATION_AUDIO_ZIP) validate-meditation-audio | $(WEB_DIST_DIR)
$(WEB_TARGET): src/web_shell.html $(WEB_BOOT_JS) $(WEB_JS_TARGET) $(WEB_CANVAS_TARGET) vendor/kryon/web/kryon-web-present.js manifest.json $(WEB_ASSET_FILES) $(MEDITATION_AUDIO_ZIP) validate-meditation-audio | $(WEB_DIST_DIR)
perl -0pe 's#\{\{\{ APP_SCRIPT \}\}\}#$(WEB_APP_SCRIPT)#g; s/WEB_CACHE_BUSTER/$(WEB_CACHE_BUSTER)/g' src/web_shell.html > $@
cp $(WEB_BOOT_JS) $(WEB_DIST_DIR)/index_boot.js
perl -0pi -e 's/WEB_CACHE_BUSTER/$(WEB_CACHE_BUSTER)/g' $(WEB_DIST_DIR)/index_boot.js
cp vendor/kryon/web/kryon-web-present.js $(WEB_DIST_DIR)/kryon-web-present.js
perl -0pi -e 's/WEB_CACHE_BUSTER/$(WEB_CACHE_BUSTER)/g' $(WEB_DIST_DIR)/kryon-web-present.js
rm -rf $(WEB_DIST_DIR)/canvas
cp -R $(WEB_CANVAS_DIR) $(WEB_DIST_DIR)/canvas
rm -rf $(WEB_DIST_DIR)/web-assets $(WEB_DIST_DIR)/site-icons
cp -R web-assets $(WEB_DIST_DIR)/
cp -R site-icons $(WEB_DIST_DIR)/
cp manifest.json $(WEB_DIST_DIR)/webmanifest.json
# Canvas-backend web build: kryon's HTML5 Canvas2D Tier A backend instead of
# raylib+GLFW — no libraylib.web.a, no WebGL. Sync-account crypto (liboqs)
# and audio are not carried in this target: scripts/ksync-canvas-shim.c
# reports sync unavailable and kryon's canvas audio is null-grade.
WEB_CANVAS_DIR := $(BUILD_DIST_DIR)/web-canvas
WEB_CANVAS_TARGET := $(WEB_CANVAS_DIR)/index.html
KRYON_CANVAS_SRCS := $(filter-out $(KRYON_DIR)/src/ksync/% $(KRYON_RAYLIB_WRAPPERS_C),$(KRYON_SRCS))
KSYNC_CANVAS_SHIM := scripts/ksync-canvas-shim.c
web-canvas: $(WEB_CANVAS_TARGET)
$(WEB_CANVAS_DIR):
@@ -1324,7 +1325,7 @@ $(WEB_CANVAS_TARGET): Makefile $(WEB_SRC) $(KRYON_CANVAS_SRCS) $(KSYNC_CANVAS_SH
-sALLOW_MEMORY_GROWTH=1 -sINITIAL_MEMORY=268435456 -sSTACK_SIZE=33554432 \
-sEXPORTED_FUNCTIONS=_main,_malloc,_free \
--preload-file locales --preload-file assets
sed 's/{{APP_TITLE}}/$(APP_TITLE)/' web-assets/canvas_index.html > $@
sed -e 's/{{APP_TITLE}}/$(APP_TITLE)/' -e 's/WEB_CACHE_BUSTER/$(WEB_CACHE_BUSTER)/g' web-assets/canvas_index.html > $@
android-copy-assets:
$(MAKE) $(FONT_FILES)
+3
View File
@@ -211,6 +211,9 @@ for path in \
build/web/index.html \
build/web/index.js \
build/web/index.wasm \
build/web/canvas/index.html \
build/web/canvas/index.js \
build/web/canvas/index.wasm \
build/telegram/index.html \
build/telegram/index.js \
build/telegram/index.wasm \
+4 -2
View File
@@ -1,6 +1,7 @@
var statusElement = document.querySelector('#status');
var progressElement = document.querySelector('#progress');
var loadingScreen = document.querySelector('#loading-screen');
var canvasFallbackPath = 'canvas/';
function storageOriginLooksPersistent() {
var protocol = window.location && window.location.protocol;
@@ -34,10 +35,11 @@ window.__inbeLoadApp = function(src) {
if (!webglAvailable()) {
if (statusElement) {
statusElement.textContent = 'WebGL is disabled. Enable WebGL in this browser to run Inner Breeze.';
statusElement.textContent = 'Starting Canvas renderer...';
}
if (progressElement) progressElement.hidden = true;
console.error('INBE: WebGL is disabled or unavailable');
console.warn('INBE: WebGL is disabled or unavailable; using Canvas renderer');
window.location.replace(canvasFallbackPath + window.location.search + window.location.hash);
return;
}
+1 -1
View File
@@ -9,4 +9,4 @@
window.requestAnimationFrame = (fn) => setTimeout(() => fn(performance.now()), 16);
Module = { canvas: document.getElementById('canvas') };
</script>
<script src="index.js"></script></body></html>
<script src="index.js?v=WEB_CACHE_BUSTER"></script></body></html>