Files
logic-puzzle/docs/BROWSER_PLAYTEST.md
2026-11-14 08:55:48 +01:00

7.1 KiB
Raw Permalink Blame History

Lumen browser playtest

This is the same Flutter game and bundled story content as the mobile app: Mara’s notebook, The paper boat (English/German), and The Midnight Invitation. The browser version has no advertising. Explained hints are free. Large desktop windows keep a centered game surface up to 1280 × 800 CSS pixels to avoid expensive full-monitor canvas rendering. Smaller and portrait viewports keep their responsive layout. Narration starts three seconds after opening a narrated page; browsers that block audio may require one tap on Play.

Hosting the ZIP

Unzip lumen-browser-playtest.zip into a directory on your web server and send friends its HTTPS URL. The directory must contain index.html, main.dart.js, flutter_bootstrap.js, canvaskit/, and assets/ together. Do not open index.html directly from the filesystem. No application backend, database, Node.js server or Apple account is needed.

Do not serve the repository's web/ directory with an IDE live server. Its flutter_bootstrap.js is a Flutter build template, not executable output; serving it directly produces flutter_js is not defined. Build the app first and serve build/web/, or use flutter run -d chrome. Deploy all files from the same build together and reload if an old bootstrap is cached.

The default build is for the root of a website, for example https://play.example.com/. If you want a subdirectory such as https://example.com/lumen/, rebuild with:

bash scripts/build_web.sh --base-href /lumen/

The leading and trailing slashes matter. The packaged index.html base href can also be changed to /lumen/ before hosting an existing ZIP there.

Serve .wasm as application/wasm, .js as application/javascript, .json as application/json, and .mp3 as audio/mpeg. Enable byte-range requests for audio (standard static-file hosting in nginx/Apache provides this). For background-thread rendering in supported browsers, serve the game with Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp. It also works without isolation, using a single rendering thread. Missing files should return 404, not an HTML fallback page. Keep the directory layout intact. Everything needed at runtime, including Flutter’s renderer, fonts and recordings, is included; there is no dependency on a font/renderer CDN.

Content Security Policy

The Flutter build compiles WebAssembly for its renderer. If the host sends a Content Security Policy, its script-src must permit WebAssembly compilation; in current browsers, 'wasm-unsafe-eval' grants that permission without also allowing JavaScript string evaluation through eval() or new Function(). For example, this is a starting policy for the standalone, same-origin build:

Content-Security-Policy: default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; connect-src 'self'; media-src 'self' blob:; worker-src 'self' blob:

Configure the policy on the hosting server; this project does not set a CSP itself. Adapt and test it for the actual host and embedding environment. Multiple policies are enforced together, so adding a permissive policy in index.html cannot override a stricter server header. Older browsers may not support 'wasm-unsafe-eval'; check the browsers you intend to support. Avoid adding the broader 'unsafe-eval' unless it is required and its security tradeoff is acceptable.

If DevTools reports a warning from contentscript.js, inspect its full URL: an extension URL (such as chrome-extension://...) identifies browser extension code, not code in the game. Recheck in a clean browser profile with extensions disabled before attributing an extension's deprecation or CSP warning to Lumen.

For updates, replace the whole build together. Serve index.html, flutter_bootstrap.js, flutter.js, narration.js, and main.dart.js with Cache-Control: no-cache. Use revalidation for assets too unless you version their URLs. This build does not install an offline service worker. Testers need a connection to load new pages, pictures and recordings.

Tell your testers

  • Open the link in Safari on iPhone/iPad or Chrome on Android/computer.
  • Choose a book from the shelf. Your first tap prepares the narrator for the automatic three-second start on story pages and postcards. Some browsers or embedded WebViews may still require you to tap Play this reading. Pause, replay and speed controls remain available. Atmosphere depends on the browser permitting audio.
  • Tap puzzle cells to cycle empty → light → crossed out. Hint offers a confirmed, explained deduction without an advertisement.
  • Bookmarks, puzzle marks, reading position and settings stay in that browser. They do not sync between devices; private browsing or clearing site data can remove them. Use a private window to start a fresh playtest.
  • Report the book, page heading, device/browser and what happened when giving feedback. Web testing covers stories, voices and gameplay; native ads and store installation still need mobile builds.

Build and verify

With the project’s supported Flutter SDK, Python Pillow and ffmpeg installed:

flutter pub get
bash scripts/build_web.sh
flutter test --no-pub

The helper builds WebAssembly with a JavaScript fallback, resolves dependencies, emits web-only WebP artwork and MP3 audio, verifies referenced assets, and produces artifacts/lumen-browser-playtest.zip. Override FLUTTER_BIN to use another SDK path. The unpacked output is build/web/.

For a local preview:

python3 -m http.server 8080 --directory build/web

Open http://localhost:8080/. Your production server should support HTTPS and audio range requests, as described above. iPhone Safari testing on a real phone is recommended before inviting a larger group.

Narration handoff regression

With a dedicated Chrome instance exposing --remote-debugging-port=9224, run this Node 22+ test against the built game preview:

node scripts/check_browser_narration.mjs http://localhost:8080/

For the Astro-hosted game, pass its /lumen/play/ URL instead. Override CHROME_DEBUG_URL if the debugger uses another port. The test creates its own fresh browser context and checks the actual playing media URL after Next, Previous and rapid page turns, without touching existing tabs or saved games.

Checking browser narration

node scripts/test_web_narration.mjs checks the audio bridge in headless Chromium with autoplay blocked until a real user gesture. It requires a built web bundle and uses the locally cached Chromium by default; set CHROME_BIN to use another binary. For the full Flutter path, serve build/web on 127.0.0.1:18765, then run node scripts/test_web_app_autoplay.mjs and LUMEN_POSTCARD=1 node scripts/test_web_app_autoplay.mjs, and LUMEN_MIDNIGHT=1 node scripts/test_web_app_autoplay.mjs. These exercise the lighthouse notebook and a leaf turn, a collected postcard in an isolated browser profile, and the Midnight Invitation opening. Each checks that the correct recording actually starts. These Chromium checks do not replace testing on iOS Safari or an embedding app's WebView.