You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The native layer has grown into a high-risk area: platform window files are large and mix window lifecycle, WebView setup, custom schemes, JS injection, dialogs, notifications, threading, and interop ownership. This makes native bugs hard to isolate and increases the chance of crashes, leaks, ABI drift, and platform-specific regressions
Current behavior
Platform/Windows/Window.cpp, Platform/Linux/Window.cpp, and Platform/Mac/Window.mm are large monoliths with many responsibilities
Exports.cpp directly dereferences InfiniFrameWindow* in most exports and has no consistent status/error contract
Native code sometimes reports fatal setup problems via UI dialogs and exit(0) instead of returning errors to managed code
String/buffer ownership differs across Windows/Linux/macOS and is manually encoded in several places
Test-only exports (Exports.Tests.cpp) are compiled into the native shared library through TEST_SOURCES
WebView custom scheme, CORS, and Blazor shim logic are embedded inside platform window setup
.clang-tidy and sanitizer intent exist, but static analysis/sanitizer coverage is not clearly enforced across native CI
Expected behavior
The native layer should have clear ownership rules, safer C ABI boundaries, smaller platform modules, test-only code excluded from production artifacts, and repeatable native quality gates
Window.Win32.cpp
- create/show/close/move/resize window only
WebView2Host.cpp
- create WebView2 environment/controller only
WebView2CustomSchemes.cpp
- scheme registration and response handling only
WebView2JsInterop.cpp
- JS injection and web message callbacks only
Notifications.WinToast.cpp
- notifications only
What about PIMPL
PIMPL would not break at all. Right now PIMPL looks like:
And different Windows .cpp can see/work around it:
// Platform/Windows/WebView2CustomSchemes.cpp
#include"WindowImpl.Win32.h"voidInfiniFrameWindow::Impl::RegisterCustomSchemes() {
// access _webviewWindow, _customSchemeNames, etc.
}
What are really prohibited in this solution:
Core/InfiniFrameWindow.h
- place HWND / GtkWidget / WKWebView into it
- show entire Impl in public header
- create a single Impl, which contain entire platforms headers
Keep fixing issues individually. This works for urgent crash bugs, but does not reduce the underlying complexity that keeps producing ownership, callback, and platform divergence defects
Use case
Maintainers need to safely add native features such as new WebView options, custom scheme behavior, packaging/AOT support, or platform-specific window functionality without re-auditing thousands of lines of mixed lifecycle and interop code each time
Technical proposal
Production InfiniFrame.Native no longer exports InfiniWindowTests_* symbols
C ABI exports have consistent precondition guards and documented return/error behavior
Common.hErrorCode / Result is either used meaningfully or removed in favor of a chosen error model
Impact
High
Problem / Motivation
The native layer has grown into a high-risk area: platform window files are large and mix window lifecycle, WebView setup, custom schemes, JS injection, dialogs, notifications, threading, and interop ownership. This makes native bugs hard to isolate and increases the chance of crashes, leaks, ABI drift, and platform-specific regressions
Current behavior
Platform/Windows/Window.cpp,Platform/Linux/Window.cpp, andPlatform/Mac/Window.mmare large monoliths with many responsibilitiesExports.cppdirectly dereferencesInfiniFrameWindow*in most exports and has no consistent status/error contractexit(0)instead of returning errors to managed codeExports.Tests.cpp) are compiled into the native shared library throughTEST_SOURCES.clang-tidyand sanitizer intent exist, but static analysis/sanitizer coverage is not clearly enforced across native CIExpected behavior
The native layer should have clear ownership rules, safer C ABI boundaries, smaller platform modules, test-only code excluded from production artifacts, and repeatable native quality gates
Proposed solution
Introduce a native hardening/refactor initiative:
instance, output pointers, and invalid arguments consistentlyExports.Tests.cppinto a dedicated test-only native target or compile it behind an explicit test flagclang-tidy,clang-format --check, and native sanitizer builds into CI where platform support allowsHow will suggestion looks on prod:
Comparsion
Before:
After:
What about PIMPL
PIMPL would not break at all. Right now PIMPL looks like:
So the correct solution after refactor must be:
So
Impljust moving from single and overcoded.cppto private platform header:And different Windows
.cppcan see/work around it:What are really prohibited in this solution:
A little compromise about it is:
Alternatives considered
Keep fixing issues individually. This works for urgent crash bugs, but does not reduce the underlying complexity that keeps producing ownership, callback, and platform divergence defects
Use case
Maintainers need to safely add native features such as new WebView options, custom scheme behavior, packaging/AOT support, or platform-specific window functionality without re-auditing thousands of lines of mixed lifecycle and interop code each time
Technical proposal
InfiniFrame.Nativeno longer exports InfiniWindowTests_* symbolsCommon.hErrorCode/Resultis either used meaningfully or removed in favor of a chosen error modelWindowfiles are reduced by extracting at least custom schemes, JS interop, and UI-thread invocationRelated issues
This refactor is related to several existing native/interop issues:
exit(0)instead of propagating errorshwnd -> instancelookup should be centralized and null-safewindow.Infiniframeto the js layer instead ofwindow.externalcalls #215, Tracker | Js Document to C# Photino events #9, Feature | Near to full control of the window in the JS layer #219 - JS/WebView/native messaging should have a clearer platform-neutral boundaryChecklist