Created
September 26, 2025 10:22
-
-
Save Kaylebor/1cc49b088a651e502b812bdb09f72149 to your computer and use it in GitHub Desktop.
Fix environment to ensure FL Studio can use installed Microsoft Edge WebView2 correctly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -Eeuo pipefail | |
| # --- WebView2 Environment Setup Script --- | |
| # Sets up the minimal working WebView2 configuration for FL Studio | |
| # --- Config ---------------------------------------------------------------- | |
| WINEPREFIX="${WINEPREFIX:-$HOME/.wine}" | |
| WINEBIN="${WINEBIN:-wine}" | |
| FL_EXE_NAME="FL64.exe" | |
| POLICY_KEY='HKCU\Software\Policies\Microsoft\Edge\WebView2\BrowserExecutableFolder' | |
| echo "Setting up WebView2 environment for FL Studio..." | |
| echo " Wine prefix: $WINEPREFIX" | |
| # --- Helper functions ------------------------------------------------------ | |
| err() { echo "ERROR: $*" >&2; exit 1; } | |
| to_win_path() { | |
| local p="${1:?missing posix path}" | |
| [[ "$p" == "$WINEPREFIX/drive_c"* ]] || err "Path not under $WINEPREFIX/drive_c: $p" | |
| local w="C:${p#"$WINEPREFIX/drive_c"}" | |
| echo "$(sed 's:/:\\\\:g' <<<"$w")" | |
| } | |
| # --- Find WebView2 runtime ------------------------------------------------ | |
| RUNTIME_ROOT="$WINEPREFIX/drive_c/Program Files (x86)/Microsoft/EdgeWebView/Application" | |
| [[ -d "$RUNTIME_ROOT" ]] || err "WebView2 runtime not found: $RUNTIME_ROOT (install WebView2 first)" | |
| echo "Finding WebView2 runtime versions..." | |
| mapfile -t versions < <(find "$RUNTIME_ROOT" -maxdepth 1 -type d -regextype posix-extended -regex '.*/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | sort -V) | |
| [[ ${#versions[@]} -gt 0 ]] || err "No versioned runtime directories found under: $RUNTIME_ROOT" | |
| LATEST_DIR="${versions[-1]}" | |
| [[ -f "$LATEST_DIR/msedgewebview2.exe" ]] || err "Runtime incomplete: $LATEST_DIR/msedgewebview2.exe missing" | |
| WIN_RUNTIME_DIR="$(to_win_path "$LATEST_DIR")" | |
| echo " Found WebView2 runtime: $WIN_RUNTIME_DIR" | |
| # --- Set FL64.exe-specific policy ----------------------------------------- | |
| echo "Setting WebView2 policy for FL64.exe..." | |
| "$WINEBIN" reg add "$POLICY_KEY" /v "$FL_EXE_NAME" /t REG_SZ /d "$WIN_RUNTIME_DIR" /f >/dev/null | |
| # --- Set single-context rendering for anti-flicker ----------------------- | |
| echo "Configuring single-context rendering to prevent flickering..." | |
| "$WINEBIN" reg add 'HKCU\Environment' /v WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS /t REG_SZ /d "--single-process --disable-gpu-sandbox --disable-software-rasterizer" /f >/dev/null | |
| # --- Restart Wine server --------------------------------------------------- | |
| "$WINEBIN" wineserver -k || true | |
| echo "WebView2 environment setup complete!" | |
| echo | |
| echo "Current configuration:" | |
| "$WINEBIN" reg query "$POLICY_KEY" /v "$FL_EXE_NAME" || true | |
| "$WINEBIN" reg query 'HKCU\Environment' /v WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS || true |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The FL64.exe policy scopes WebView2 DLL/EXE paths to the executable, fixing white webviews without impacting other applications in the prefix.
WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTSfixes flickering, mainly by running all WebViews in the prefix in a single context.This assumes that the runtime was installed from here (install the Evergreen Standalone Installer, NOT the Evergreen Bootstrapper; the Fixed Version may also work. Tested with
140.0.3482.81)