Skip to content

Conversation

@leaanthony
Copy link
Member

@leaanthony leaanthony commented Nov 13, 2025

Reorder initialisation of webview2

Potentially Fixes #4694

Summary by CodeRabbit

  • Bug Fixes

    • Resolved Windows "Not enough memory" errors during WebView2 startup by changing when drag-and-drop is configured, improving startup reliability on Windows.
    • Added additional startup diagnostics to aid troubleshooting.
  • Chores

    • Bumped go-webview2 dependency to v1.0.23.

✏️ Tip: You can customize this high-level summary in your review settings.

leaanthony and others added 3 commits November 11, 2025 22:25
Fixes the "Not enough memory resources" error by moving AllowExternalDrag call
after chromium.Embed(). This critical initialization order issue was causing
drag-and-drop to fail with WebView2 v142.

## Changes
- Move AllowExternalDrag(false) call to after chromium.Embed()
- Add capability check using chromium.HasCapability(edge.AllowExternalDrop)
- Change condition from DisableWebViewDrop to EnableFileDrop for clarity
- Add comments explaining the initialization order requirement

## Technical Details
The issue occurred because AllowExternalDrag was called before the WebView2
was properly embedded, causing it to fail with insufficient memory errors.
This particularly affected users with WebView2 v142.

When EnableFileDrop is true, Wails handles file drops, so we disable the
WebView's native external drag to prevent automatic file opening.

Fixes #4701, #4700, #4694

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Updated go-webview2 dependency from v1.0.22 to v1.0.23
- Added changelog entry for WebView2 initialization order fix
- Added changelog entry for go-webview2 update

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@github-actions github-actions bot added Documentation Improvements or additions to documentation Windows v2-only labels Nov 13, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Walkthrough

Moved WebView2 drag-and-drop configuration to run after chromium.Embed(), added logging around embed and request processing, bumped go-webview2 to v1.0.23, and updated changelog entries documenting the init-order fix.

Changes

Cohort / File(s) Summary
Dependency Update
v2/go.mod
Bumps github.com/wailsapp/go-webview2 from v1.0.22 to v1.0.23.
WebView2 Initialization Order
v2/internal/frontend/desktop/windows/frontend.go
Removes pre-Embed drag-and-drop call; adds post-Embed check for edge.AllowExternalDrop and calls chromium.AllowExternalDrag(false) when appropriate; adds logging before/after chromium.Embed() and logs URIs in processRequest. Includes error logging when AllowExternalDrag fails.
Documentation
website/src/pages/changelog.mdx
Adds Unreleased Fixed note about Windows WebView2 initialization order memory errors and notes go-webview2 bump under v2.11.0 Changed.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant WebView2
    participant Chromium

    rect rgb(255,240,245)
    note over App,WebView2: Previous flow (pre-embed config)
    App->>WebView2: Configure AllowExternalDrag(false)
    App->>WebView2: Embed control
    WebView2->>Chromium: Initialize
    end

    rect rgb(240,255,245)
    note over App,WebView2: New flow (post-embed config)
    App->>WebView2: Embed control
    WebView2->>Chromium: Initialize
    App->>Chromium: Check edge.AllowExternalDrop capability
    alt capability present
        App->>Chromium: AllowExternalDrag(false)
        Chromium-->>App: success / error
        App->>App: Log result (success or detailed error)
    else capability absent
        App->>App: Log capability absent
    end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Changes are localized but include a timing-sensitive initialization change and dependency bump.
  • Review focus suggested:
    • v2/internal/frontend/desktop/windows/frontend.go: verify Embed() logging, post-embed capability check, error handling, and any potential race/timing concerns.
    • Ensure chromium.AllowExternalDrag(false) invocation is safe post-Embed across supported WebView2 versions.
    • Confirm changelog wording in website/src/pages/changelog.mdx matches release policy.

Possibly related PRs

Suggested labels

Bug, size:M

Poem

🐰 In timing’s hop I found the cue,
Post-embed I nudge WebView2.
Logs now sing where silence grew,
No memory scares — a lighter view.
thump-thump 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal and lacks key details from the template such as issue reference, type of change, testing details, and required checklist items. Include explicit 'Fixes #4694' reference, select bug fix type, describe testing performed, and complete the provided checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'Fix/webview2 initialization order' is clear and specific, accurately describing the main change made to address WebView2 initialization issues.
Linked Issues check ✅ Passed The code changes directly address the linked issue #4694 by reordering WebView2 initialization to execute drag-and-drop configuration after chromium.Embed() to resolve memory-related issues causing initialization failures.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the WebView2 initialization issue: dependency update for go-webview2, reordered initialization logic, added logging, and changelog updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/webview2-initialization-order

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 148fd28 and 7c74e27.

📒 Files selected for processing (1)
  • v2/internal/frontend/desktop/windows/frontend.go (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-17T23:16:11.570Z
Learnt from: Sammy-T
Repo: wailsapp/wails PR: 4570
File: v2/internal/frontend/desktop/linux/window_webkit6.go:97-108
Timestamp: 2025-10-17T23:16:11.570Z
Learning: For webkit_6/GTK4 builds in v2/internal/frontend/desktop/linux/window_webkit6.go, GTK widget creation should not be wrapped in invokeOnMainThread. The activation mechanism (activateWg + onActivate export) already handles thread safety, and additional wrapping would cause issues.

Applied to files:

  • v2/internal/frontend/desktop/windows/frontend.go
📚 Learning: 2025-08-08T09:13:16.916Z
Learnt from: APshenkin
Repo: wailsapp/wails PR: 4480
File: v2/internal/frontend/desktop/darwin/message.h:17-19
Timestamp: 2025-08-08T09:13:16.916Z
Learning: In Wails v2 bindings origin verification, processBindingMessage intentionally has different signatures across platforms: Darwin includes an isMainFrame bool (WKWebKit provides it), Linux uses two params (message, source) as WebKitGTK doesn’t expose main-frame info there, and Windows handles origin checks in Go via WebView2 sender/args without a C bridge. This divergence is acceptable/expected per maintainer (APshenkin).

Applied to files:

  • v2/internal/frontend/desktop/windows/frontend.go
🧬 Code graph analysis (1)
v2/internal/frontend/desktop/windows/frontend.go (1)
v2/pkg/options/options.go (1)
  • DragAndDrop (201-216)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Run Go Tests (windows-latest, 1.23)
  • GitHub Check: Run Go Tests (ubuntu-22.04, 1.23)
  • GitHub Check: Run Go Tests (ubuntu-24.04, 1.23)
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (go)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (3)
v2/internal/frontend/desktop/windows/frontend.go (3)

542-544: Good debugging instrumentation for initialization tracking.

The debug logging around chromium.Embed() will help diagnose timing issues related to the blank window / WebView2 process failures mentioned in issue #4694.


546-558: Excellent fix for WebView2 initialization order.

Moving drag-and-drop configuration to run after chromium.Embed() directly addresses the "Not enough memory" errors and initialization issues mentioned in the PR objectives. The implementation:

  • Correctly checks EnableFileDrop and capability support
  • Includes appropriate error handling and logging
  • Documents the rationale with clear comments

655-655: Good addition for request debugging.

The URI logging in processRequest will help diagnose any asset loading or routing issues that might contribute to blank window problems.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5deb16 and 148fd28.

⛔ Files ignored due to path filters (1)
  • v2/go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • v2/go.mod (1 hunks)
  • v2/internal/frontend/desktop/windows/frontend.go (1 hunks)
  • website/src/pages/changelog.mdx (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:29-30
Timestamp: 2025-08-08T10:25:32.415Z
Learning: For Wails v3 Linux nfpm template, Debian/Ubuntu WebKitGTK runtime package names differ: Debian 12 (Bookworm) uses libwebkit2gtk-4.1-0 while Ubuntu 22.04 (Jammy) uses libwebkit2gtk-4.0-37. Prefer an OR dependency "libwebkit2gtk-4.1-0 | libwebkit2gtk-4.0-37" in v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl to support both.
📚 Learning: 2025-10-17T23:16:11.570Z
Learnt from: Sammy-T
Repo: wailsapp/wails PR: 4570
File: v2/internal/frontend/desktop/linux/window_webkit6.go:97-108
Timestamp: 2025-10-17T23:16:11.570Z
Learning: For webkit_6/GTK4 builds in v2/internal/frontend/desktop/linux/window_webkit6.go, GTK widget creation should not be wrapped in invokeOnMainThread. The activation mechanism (activateWg + onActivate export) already handles thread safety, and additional wrapping would cause issues.

Applied to files:

  • v2/internal/frontend/desktop/windows/frontend.go
🧬 Code graph analysis (1)
v2/internal/frontend/desktop/windows/frontend.go (1)
v2/pkg/options/options.go (1)
  • DragAndDrop (201-216)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Run Go Tests (ubuntu-22.04, 1.23)
  • GitHub Check: Run Go Tests (ubuntu-24.04, 1.23)
  • GitHub Check: Run Go Tests (windows-latest, 1.23)
  • GitHub Check: semgrep/ci
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
website/src/pages/changelog.mdx (2)

17-19: Verify the additional issue references are intentional.

The changelog references issues #4701, #4700, and #4694, but the PR description only mentions #4694. Confirm that all three issues are addressed by this fix.


39-40: LGTM!

The documentation correctly notes the go-webview2 dependency update to v1.0.23 under the v2.11.0 release.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 13, 2025

Deploying wails with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7c74e27
Status: ✅  Deploy successful!
Preview URL: https://44013176.wails.pages.dev
Branch Preview URL: https://fix-webview2-initialization.wails.pages.dev

View logs

@sonarqubecloud
Copy link

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

Labels

Documentation Improvements or additions to documentation v2-only Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blank Window with ERR | WebVie2wProcess failed with kind 1 on Windows 10

2 participants