# Refrax – my Arc Browser replacement I made from scratch

Open the same tab in two browser windows. In Chrome or Safari, you get two unconnected pages. In Arc, one window shows a placeholder. In Zen, it silently creates a duplicate. In Refrax, the browser I built, both windows show the same page updating live. The same web page, in as many windows as you…

- **Page:** https://magpie.gallery/i/refrax-my-arc-browser-replacement-i-made-from-scra-h8ca
- **Type:** Link to an idea elsewhere
- **Category:** Utilities
- **Runs on:** macos
- **Tags:** browser, webkit, tabs, swiftui

## Source

Web · kageroumado: Refrax – my Arc Browser replacement I made from scratch

- **Original:** https://news.ycombinator.com/item?id=47483155

> Open the same tab in two browser windows. In Chrome or Safari, you get two unconnected pages. In Arc, one window shows a placeholder. In Zen, it silently creates a duplicate. In Refrax, the browser I built, both windows show the same page updating live. The same web page, in as many windows as you want. This shouldn't be possible. WebKit's WKWebView can exist in exactly one view hierarchy at a time. With macOS 26, Apple added a SwiftUI API separating WebView from WebPage, so you can end up with multiple views referencing the same page. But if you try it, your app crashes. WebKit source code has a precondition with this comment: "We can't have multiple owning pages regardless, but we'll want to decide if it's an error, if we can handle it gracefully, and how deterministic it might even be..." So here's how I did it. CAPortalLayer is an undocumented private class that's been in macOS since 10.12. It mirrors a layer's composited output by referencing the same GPU memory, not copying it. Every scroll, animation, or repaint reflects instantly. This is what powers Liquid Glass effects, the iOS text selection magnifier, and ghost images during drag and drop. Apple uses portals for effects. I use them to put the same web page in two windows. Refrax keeps one real WKWebView per tab and displays a CAPortalLayer mirror everywhere else. When you click a different window, the coordinator moves the real view there and the old window gets a portal. You can't tell which is which. This sounds simple in theory, but making this actually work seamlessly took quite a lot of effort. Each macOS window has its own rendering context, and the context ID updates asynchronously, so creating a portal immediately captures a stale ID and renders nothing. The portal creation needs to be delayed, but delaying creates a visual gap. I capture a GPU snapshot using a private CoreGraphics function and place it behind the portal as a fallback. Another hard part is that none of it is documented. Portals a

## Rules for reuse

- Build your own version: don't copy another product's code, look, icons, colours or copy.
- The original belongs to its author; Magpie only links to it.
- The original content's copyright belongs to its creator. Magpie doesn't download or re-upload it; we only show the link and the official preview.
