Skip to content

Commit 84efc00

Browse files
authored
Only apply subsystem to final binary, not cdylibs (#5002)
1 parent 75d9ece commit 84efc00

File tree

10 files changed

+177
-60
lines changed

10 files changed

+177
-60
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,22 @@ jobs:
220220
playwright:
221221
if: github.event.pull_request.draft == false
222222
name: Playwright Tests
223-
runs-on: blacksmith-8vcpu-ubuntu-2404
223+
runs-on: ${{ matrix.os }}
224224
timeout-minutes: 45
225225
strategy:
226226
matrix:
227+
os: [windows-latest, blacksmith-8vcpu-ubuntu-2404]
227228
platform:
228229
- { toolchain: beta }
229230
# - { toolchain: 1.86.0 }
230231
steps:
231232
# Do our best to cache the toolchain and node install steps
232233
- uses: actions/checkout@v5
233234
- name: Free Disk Space
234-
if: ${{ matrix.platform.os == 'ubuntu-24.04' || matrix.platform.os == 'ubuntu-24.04-arm' || matrix.platform.os == 'blacksmith-4vcpu-ubuntu-2404' || matrix.platform.os == 'blacksmith-4vcpu-ubuntu-2404-arm' }}
235+
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'ubuntu-24.04-arm' || matrix.os == 'blacksmith-4vcpu-ubuntu-2404' || matrix.os == 'blacksmith-4vcpu-ubuntu-2404-arm' || matrix.os == 'blacksmith-8vcpu-ubuntu-2404' }}
235236
uses: ./.github/actions/free-disk-space
236237
- uses: awalsh128/cache-apt-pkgs-action@latest
238+
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'ubuntu-24.04-arm' || matrix.os == 'blacksmith-4vcpu-ubuntu-2404' || matrix.os == 'blacksmith-4vcpu-ubuntu-2404-arm' || matrix.os == 'blacksmith-8vcpu-ubuntu-2404' }}
237239
with:
238240
packages: glib-networking glib-networking-common glib-networking-services libaa1 libabsl20220623t64 libass9 libasyncns0 libavc1394-0 libavcodec60 libavfilter9 libavformat60 libavtp0 libavutil58 libblas3 libbluray2 libbs2b0 libcaca0 libcairo-script-interpreter2 libcdparanoia0 libchromaprint1 libcjson1 libcodec2-1.2 libdav1d7 libdc1394-25 libdca0 libdecor-0-0 libdirectfb-1.7-7t64 libdv4t64 libdvdnav4 libdvdread8t64 libfaad2 libflac12t64 libfluidsynth3 libfreeaptx0 libgav1-1 libgme0 libgraphene-1.0-0 libgsm1 libgssdp-1.6-0 libgstreamer-plugins-good1.0-0 libgtk-4-common libgupnp-1.6-0 libgupnp-igd-1.6-0 libhwy1t64 libiec61883-0 libimath-3-1-29t64 libinstpatch-1.0-2 libjack-jackd2-0 libjxl0.7 liblapack3 liblc3-1 libldacbt-enc2 liblilv-0-0 liblrdf0 libltc11 libmbedcrypto7t64 libmfx1 libmjpegutils-2.1-0t64 libmodplug1 libmp3lame0 libmpcdec6 libmpeg2encpp-2.1-0t64 libmpg123-0t64 libmplex2-2.1-0t64 libmysofa1 libneon27t64 libnice10 libogg0 libopenal-data libopenal1 libopenexr-3-1-30 libopenh264-7 libopenmpt0t64 libopenni2-0 liborc-0.4-0t64 libpipewire-0.3-0t64 libplacebo338 libpocketsphinx3 libpostproc57 libproxy1v5 libpulse0 libqrencode4 libraptor2-0 librav1e0 libraw1394-11 librist4 librubberband2 libsamplerate0 libsbc1 libsdl2-2.0-0 libsecret-common libserd-0-0 libshine3 libshout3 libsndfile1 libsndio7.0 libsord-0-0 libsoundtouch1 libsoup-3.0-0 libsoup-3.0-common libsoxr0 libspa-0.2-modules libspandsp2t64 libspeex1 libsphinxbase3t64 libsratom-0-0 libsrt1.5-gnutls libsrtp2-1 libssh-gcrypt-4 libsvtav1enc1d1 libswresample4 libswscale7 libtag1v5 libtag1v5-vanilla libtheora0 libtwolame0 libudfread0 libunibreak5 libv4l-0t64 libv4lconvert0t64 libva-drm2 libva-x11-2 libva2 libvdpau1 libvidstab1.1 libvisual-0.4-0 libvo-aacenc0 libvo-amrwbenc0 libvorbis0a libvorbisenc2 libvorbisfile3 libvpl2 libwavpack1 libwebrtc-audio-processing1 libwildmidi2 libx265-199 libxcb-xkb1 libxkbcommon-x11-0 libcups2t64 libxml2 libxml2-dev libxvidcore4 libyuv0 libzbar0t64 libzimg2 libzix-0-0 libzvbi-common libzvbi0t64 libzxing3 ocl-icd-libopencl1 timgm6mb-soundfont xfonts-encodings xfonts-utils binutils lld binutils-devel binutils-gold fonts-freefont-ttf fonts-ipafont-gothic fonts-tlwg-loma-otf fonts-unifont fonts-wqy-zenhei gstreamer1.0-libav gstreamer1.0-plugins-bad gstreamer1.0-plugins-good libavif16 libevent-2.1-7t64 libgstreamer-plugins-bad1.0-0 libharfbuzz-icu0 libhyphen0 libmanette-0.2-0 libsecret-1-0 libwoff1 xfonts-cyrillic xfonts-scalable fonts-ipafont-mincho fonts-tlwg-loma gstreamer1.0-x
239241
version: 1.0
@@ -251,6 +253,7 @@ jobs:
251253
cache-all-crates: "true"
252254
cache-on-failure: "true"
253255
- name: Wipe dx cache
256+
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'ubuntu-24.04-arm' || matrix.os == 'blacksmith-4vcpu-ubuntu-2404' || matrix.os == 'blacksmith-4vcpu-ubuntu-2404-arm' || matrix.os == 'blacksmith-8vcpu-ubuntu-2404' }}
254257
run: |
255258
rm -rf ./target/dx
256259
- name: Playwright

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ members = [
138138
"packages/playwright-tests/cli-optimization",
139139
"packages/playwright-tests/wasm-split-harness",
140140
"packages/playwright-tests/default-features-disabled",
141-
"packages/playwright-tests/fullstack-error-codes",
141+
"packages/playwright-tests/fullstack-error-codes", "packages/playwright-tests/windows-headless",
142142
]
143143

144144
[workspace.package]

packages/cli/src/build/request.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ pub(crate) struct BuildRequest {
400400
pub(crate) apple_team_id: Option<String>,
401401
pub(crate) session_cache_dir: PathBuf,
402402
pub(crate) raw_json_diagnostics: bool,
403+
pub(crate) windows_subsystem: Option<String>,
403404
}
404405

405406
/// dx can produce different "modes" of a build. A "regular" build is a "base" build. The Fat and Thin
@@ -909,27 +910,6 @@ impl BuildRequest {
909910
]);
910911
}
911912

912-
// On windows, we pass /SUBSYSTEM:WINDOWS to prevent a console from appearing
913-
if matches!(bundle, BundleFormat::Windows)
914-
&& !rustflags
915-
.flags
916-
.iter()
917-
.any(|f| f.starts_with("-Clink-arg=/SUBSYSTEM:"))
918-
{
919-
let subsystem = args
920-
.windows_subsystem
921-
.clone()
922-
.unwrap_or_else(|| "WINDOWS".to_string());
923-
rustflags
924-
.flags
925-
.push(format!("-Clink-arg=/SUBSYSTEM:{}", subsystem));
926-
// We also need to set the entry point to mainCRTStartup to avoid windows looking
927-
// for a WinMain function
928-
rustflags
929-
.flags
930-
.push("-Clink-arg=/ENTRY:mainCRTStartup".to_string());
931-
}
932-
933913
// Make sure we set the sysroot for ios builds in the event the user doesn't have it set
934914
if matches!(bundle, BundleFormat::Ios) {
935915
let xcode_path = Workspace::get_xcode_path()
@@ -1040,6 +1020,7 @@ impl BuildRequest {
10401020
apple_entitlements: args.apple_entitlements.clone(),
10411021
apple_team_id: args.apple_team_id.clone(),
10421022
raw_json_diagnostics: args.raw_json_diagnostics,
1023+
windows_subsystem: args.windows_subsystem.clone(),
10431024
})
10441025
}
10451026

@@ -2673,6 +2654,25 @@ impl BuildRequest {
26732654
cargo_args.push("--".to_string());
26742655
cargo_args.extend(self.extra_rustc_args.clone());
26752656

2657+
// On windows, we pass /SUBSYSTEM:WINDOWS to prevent a console from appearing
2658+
if matches!(self.bundle, BundleFormat::Windows)
2659+
&& !self
2660+
.rustflags
2661+
.flags
2662+
.iter()
2663+
.any(|f| f.starts_with("-Clink-arg=/SUBSYSTEM:"))
2664+
{
2665+
let subsystem = self
2666+
.windows_subsystem
2667+
.clone()
2668+
.unwrap_or_else(|| "WINDOWS".to_string());
2669+
2670+
cargo_args.push(format!("-Clink-arg=/SUBSYSTEM:{}", subsystem));
2671+
// We also need to set the entry point to mainCRTStartup to avoid windows looking
2672+
// for a WinMain function
2673+
cargo_args.push("-Clink-arg=/ENTRY:mainCRTStartup".to_string());
2674+
}
2675+
26762676
// The bundle splitter needs relocation data to create a call-graph.
26772677
// This will automatically be erased by wasm-opt during the optimization step.
26782678
if self.bundle == BundleFormat::Web && self.wasm_split {

packages/desktop/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub struct Config {
6767
pub(crate) window_close_behavior: WindowCloseBehaviour,
6868
pub(crate) custom_event_handler: Option<CustomEventHandler>,
6969
pub(crate) disable_file_drop_handler: bool,
70+
pub(crate) additional_windows_args: Option<String>,
7071

7172
#[allow(clippy::type_complexity)]
7273
pub(crate) on_window: Option<Box<dyn FnMut(Arc<Window>, &mut VirtualDom) + 'static>>,
@@ -118,6 +119,7 @@ impl Config {
118119
custom_event_handler: None,
119120
disable_file_drop_handler: false,
120121
on_window: None,
122+
additional_windows_args: None,
121123
}
122124
}
123125

@@ -312,6 +314,12 @@ impl Config {
312314
self.on_window = Some(Box::new(f));
313315
self
314316
}
317+
318+
/// Add additional windows only launch arguments for webview2
319+
pub fn with_windows_browser_args(mut self, additional_args: impl ToString) -> Self {
320+
self.additional_windows_args = Some(additional_args.to_string());
321+
self
322+
}
315323
}
316324

317325
impl Default for Config {

packages/desktop/src/webview.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,14 @@ impl WebviewInstance {
442442
None
443443
};
444444

445+
#[cfg(target_os = "windows")]
446+
{
447+
use wry::WebViewBuilderExtWindows;
448+
if let Some(additional_windows_args) = &cfg.additional_windows_args {
449+
webview = webview.with_additional_browser_args(additional_windows_args);
450+
}
451+
}
452+
445453
#[cfg(any(
446454
target_os = "windows",
447455
target_os = "macos",

packages/playwright-tests/playwright.config.js

Lines changed: 60 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,24 @@ const path = require("path");
88
*/
99
// require('dotenv').config();
1010

11-
/**
12-
* @see https://playwright.dev/docs/test-configuration
13-
*/
14-
module.exports = defineConfig({
15-
testDir: ".",
16-
/* Run tests in files in parallel */
17-
fullyParallel: true,
18-
/* Fail the build on CI if you accidentally left test.only in the source code. */
19-
forbidOnly: !!process.env.CI,
20-
/* Retry on CI only */
21-
retries: process.env.CI ? 2 : 0,
22-
/* Opt out of parallel tests on CI. */
23-
workers: process.env.CI ? 1 : undefined,
24-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
25-
reporter: "html",
26-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
27-
use: {
28-
/* Base URL to use in actions like `await page.goto('/')`. */
29-
// baseURL: 'http://127.0.0.1:3000',
30-
31-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
32-
trace: "retain-on-failure",
33-
// Increase the timeout for navigations to give dx time to build the project
34-
navigationTimeout: 50 * 60 * 1000,
35-
},
36-
37-
timeout: 50 * 60 * 1000,
38-
39-
/* Configure projects for major browsers */
40-
projects: [
11+
let webServer = [];
12+
let grep = undefined;
13+
let grepInvert = undefined;
14+
if (process.platform === "win32") {
15+
webServer = [
4116
{
42-
name: "chromium",
43-
use: { ...devices["Desktop Chrome"] },
17+
cwd: path.join(process.cwd(), "windows-headless"),
18+
command:
19+
"cargo run --package dioxus-cli --release -- run --force-sequential",
20+
port: 8787,
21+
timeout: 50 * 60 * 1000,
22+
reuseExistingServer: !process.env.CI,
23+
stdout: "pipe",
4424
},
45-
],
46-
47-
/* Run your local dev server before starting the tests */
48-
webServer: [
25+
];
26+
grep = /windows/;
27+
} else {
28+
webServer = [
4929
{
5030
command:
5131
"cargo run --package dioxus-playwright-liveview-test --bin dioxus-playwright-liveview-test",
@@ -224,5 +204,49 @@ module.exports = defineConfig({
224204
reuseExistingServer: !process.env.CI,
225205
stdout: "pipe",
226206
},
207+
];
208+
209+
grepInvert = /windows/;
210+
}
211+
212+
/**
213+
* @see https://playwright.dev/docs/test-configuration
214+
*/
215+
module.exports = defineConfig({
216+
testDir: ".",
217+
/* Run tests in files in parallel */
218+
fullyParallel: true,
219+
/* Fail the build on CI if you accidentally left test.only in the source code. */
220+
forbidOnly: !!process.env.CI,
221+
/* Retry on CI only */
222+
retries: process.env.CI ? 2 : 0,
223+
/* Opt out of parallel tests on CI. */
224+
workers: process.env.CI ? 1 : undefined,
225+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
226+
reporter: "html",
227+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
228+
use: {
229+
/* Base URL to use in actions like `await page.goto('/')`. */
230+
// baseURL: 'http://127.0.0.1:3000',
231+
232+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
233+
trace: "retain-on-failure",
234+
// Increase the timeout for navigations to give dx time to build the project
235+
navigationTimeout: 50 * 60 * 1000,
236+
},
237+
238+
timeout: 50 * 60 * 1000,
239+
240+
/* Configure projects for major browsers */
241+
projects: [
242+
{
243+
name: "chromium",
244+
grep,
245+
grepInvert,
246+
use: { ...devices["Desktop Chrome"] },
247+
},
227248
],
249+
250+
/* Run your local dev server before starting the tests */
251+
webServer,
228252
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "windows-headless"
3+
edition = "2024"
4+
version.workspace = true
5+
6+
[dependencies]
7+
dioxus = { workspace = true, features = ["desktop"] }
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use dioxus::LaunchBuilder;
2+
use dioxus::prelude::*;
3+
4+
fn main() {
5+
LaunchBuilder::new()
6+
.with_cfg(
7+
dioxus::desktop::Config::new()
8+
.with_windows_browser_args("--remote-debugging-port=8787"),
9+
)
10+
.launch(app);
11+
}
12+
13+
fn app() -> Element {
14+
let mut count = use_signal(|| 0);
15+
16+
rsx! {
17+
h1 { "High-five counter: {count}" }
18+
button {
19+
id: "increment-button",
20+
onclick: move |_| count += 1, "Up high!"
21+
}
22+
}
23+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { expect, defineConfig } = require("@playwright/test");
2+
import { test as base } from '@playwright/test';
3+
import fs from 'fs';
4+
import os from 'os';
5+
import path from 'path';
6+
import childProcess from 'child_process';
7+
8+
9+
export const test = base.extend({
10+
browser: async ({ playwright }, use, testInfo) => {
11+
const browser = await playwright.chromium.connectOverCDP(`http://127.0.0.1:8787`);
12+
await use(browser);
13+
await browser.close();
14+
},
15+
context: async ({ browser }, use) => {
16+
const context = browser.contexts()[0];
17+
await use(context);
18+
},
19+
page: async ({ context }, use) => {
20+
const page = context.pages()[0];
21+
await use(page);
22+
},
23+
});
24+
25+
test("button click", async ({ page }) => {
26+
// Expect the page to contain the counter text.
27+
const main = page.locator("#main");
28+
await expect(main).toContainText("High-five counter: 0");
29+
30+
// Click the increment button.
31+
let button = page.locator("button#increment-button");
32+
await button.click();
33+
34+
// Expect the page to contain the updated counter text.
35+
await expect(main).toContainText("High-five counter: 1");
36+
});
37+

0 commit comments

Comments
 (0)