update gpui

This commit is contained in:
2026-09-01 07:58:40 +07:00
parent f7f1ea7438
commit 3290f71fa4
6 changed files with 69 additions and 52 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ console_log = "1.0"
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
js-sys = "0.3"
web-sys = { version = "0.3", features = ["Window", "Performance"] }
web-sys = { version = "0.3", features = ["Window", "Performance", "Location"] }
universal-time = { git = "https://github.com/shadowylab/universal-time" }
[target.'cfg(target_arch = "wasm32")'.dependencies]
+1 -1
View File
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly"
components = ["rustfmt", "clippy"]
components = ["rustfmt", "clippy", "rust-src"]
targets = ["wasm32-unknown-unknown"]
+4 -1
View File
@@ -36,10 +36,13 @@ if [[ "$(uname)" == "Darwin" ]]; then
fi
# Step 1: Build WASM
#
# Target features and link args (atomics, shared memory, TLS exports) come
# from `web/.cargo/config.toml`, which also enables `-Z build-std` so std is
# rebuilt with atomics support.
echo -e "${GREEN}Step 1: Building WASM...${NC}"
cd "$PROJECT_ROOT"
export CARGO_TARGET_DIR="$PROJECT_ROOT/target"
RUSTFLAGS='-C target-feature=+bulk-memory -C link-arg=--max-memory=4294967296' \
cargo build --target wasm32-unknown-unknown $RELEASE_FLAG
# Determine the build directory
+28 -1
View File
@@ -31,6 +31,30 @@ impl MonotonicClock for CustomTimeProvider {
define_time_provider!(CustomTimeProvider);
/// Returns the preferred WebGPU/WebGL backend, selected with
/// `?backend=webgpu` / `?backend=webgl` in the page URL.
#[cfg(target_family = "wasm")]
fn requested_backend() -> gpui_platform::WebBackendPreference {
let search = web_sys::window()
.and_then(|window| window.location().search().ok())
.unwrap_or_default();
if search
.trim_start_matches('?')
.split('&')
.any(|parameter| parameter == "backend=webgpu")
{
gpui_platform::WebBackendPreference::WebGpu
} else if search
.trim_start_matches('?')
.split('&')
.any(|parameter| parameter == "backend=webgl")
{
gpui_platform::WebBackendPreference::WebGl
} else {
gpui_platform::WebBackendPreference::Auto
}
}
thread_local! {
static APPLICATION: RefCell<Option<ApplicationHandle>> = const { RefCell::new(None) };
}
@@ -96,7 +120,10 @@ pub async fn run() -> Result<(), JsValue> {
// immediately instead of waiting for a repaint.
assets.preload().await;
gpui_platform::single_threaded_web().with_assets(assets)
// Multithreaded web: background work (image decoding, network
// fetches, CPU-heavy tasks) runs on real worker threads instead of
// the main thread, so the UI stays responsive.
gpui_platform::application_with_web_backend(requested_backend()).with_assets(assets)
};
let launch = move |cx: &mut App| {