MAJOR FIX: Duplicate web instances#297
Merged
jonathancaudill merged 3 commits intonook-browser:devfrom Feb 17, 2026
Merged
Conversation
…e RAM usage
**Problem:**
Each tab was creating TWO WKWebView instances:
1. Tab's lazy 'primary' WebView (created on first access, never displayed)
2. Window-specific WebView (created for display)
This resulted in double RAM usage in Activity Monitor (2 WebContent processes per tab).
**Solution:**
Implemented smart WebView assignment system:
1. **Tab.swift:**
- Added primaryWindowId tracking to know which window owns the WebView
- Added assignedWebView property that only returns WebView if assigned
- Added assignWebViewToWindow() method for explicit assignment
2. **WebViewCoordinator.swift:**
- Added getOrCreateWebView() that intelligently assigns WebViews
- First window gets 'primary' WebView (assigned to tab)
- Additional windows get 'clone' WebViews
- Added createPrimaryWebView() and createCloneWebView() methods
- Refactored createWebView() to use internal implementation
3. **WebsiteView.swift:**
- Updated webView() method to use smart assignment
- Now calls getOrCreateWebView() instead of separate get/create
4. **Lazy initialization elimination:**
- Removed forced lazy initialization in TabManager (lines 2158, 2344)
- Updated ExtensionManager, PiPManager, MediaControlsManager,
ExtensionBridge, and Navigation menus to use assignedWebView
**Result:**
- Single window: 1 WebView per tab (was 2)
- Multi-window: 1 WebView per window per tab (no waste)
- Expected 50% RAM reduction in single-window mode
…ent objects **Problem:** Creating a new window caused a crash: 'No Observable object of type AIService found' The SidebarAIChat view requires AIService and AIConfigService via @Environment, but they weren't being passed when BrowserManager created new windows manually. **Solution:** 1. Added aiService and aiConfigService weak references to BrowserManager 2. Wired these services in NookApp.setupApplicationLifecycle() 3. Added .environment(aiService) and .environment(aiConfigService) to both: - createNewWindow() - createIncognitoWindow() Also added missing .nookSettings environment to createIncognitoWindow() for consistency.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
duplicate web instances were being created in an attempt to prepare for multi window sync. This should be a MAJOR performance increase!