Skip to content

v0.12.6 Bugfix dead init and set html before run#1314

Open
citkane wants to merge 37 commits into
webview:masterfrom
citkane:Bugfix-dead-`init`-and-`set_html`-before-`run`
Open

v0.12.6 Bugfix dead init and set html before run#1314
citkane wants to merge 37 commits into
webview:masterfrom
citkane:Bugfix-dead-`init`-and-`set_html`-before-`run`

Conversation

@citkane

@citkane citkane commented Jun 18, 2025

Copy link
Copy Markdown
Contributor

This is a bugfix release that fixes inconsistent behaviour between OS platforms in a bind(); init(); run(); or bind(); set_html(); run(); call sequence.
Depending on platform, the bound script, init script or <script> tags are never processed, leading to silent failure.

Fixed

  • bound functions for init scripts and HTML scripts will execute consistentently across platforms.

Changed

  • If the user owns the window, Linux and Mac will call "set_html` after the main Webview script injection. This ensures that the DOM is ready to recieve scripts.
  • If the user owns the window, Windows will reload the browser location after pre-dom script injection, ensuring that the scripts are triggered.

Depends on PR's

citkane added 30 commits June 12, 2025 15:00
…ew_cc and complete define/implement refactoring.
Comment on lines +233 to +250
user_script add_user_script_impl(const std::string &js) override {
auto wjs = win_string::widen_string(js);
std::wstring script_id;
bool done{};
webview2_user_script_added_handler handler{[&](HRESULT res, LPCWSTR id) {
if (SUCCEEDED(res)) {
script_id = id;
// We need a reload, else the user script will never execute unless the user explicitly calls
// `navigate` after `init`
if (owns_window()) {
reload_browser_window();
}
} else {
console.error("Windows failed to add user script.",
static_cast<webview_error_t>(res));
}
done = true;
}};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With reference to #1255

@SteffenL and @AlbertXingZhang, as far as Heisenburg bugs are concerned, I did manage to observe this error log being triggered once during a CI tests run. Re-running the failed test subsequently succeeded.

If not for the error log, the only symptom was that the windows test timed out (which is the mystery symptom...).
My memory is 98% clear on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant