Skip to content

Commit fe4f0d0

Browse files
[release/8.0-preview5] [Blazor] Fix WebView JavaScript boot bug (#48594)
# [Blazor] Fix WebView JavaScript boot bug Fixes an issue where the WebView IPC receiver starts before the JavaScript dispatcher object gets initialized, preventing all Blazor Hybrid apps from starting. ## Description Due to some recent major changes in this area, a WebView-specific initialization order bug was introduced that prevents Blazor Hybrid apps from booting correctly. Unblocks dotnet/maui#15415 ## Customer Impact Very large. All Blazor Hybrid apps will fail to start without a workaround. ## Regression? - [X] Yes - [ ] No Regressed from .NET 8.0 Preview 4 ## Risk - [ ] High - [ ] Medium - [X] Low The fix is very isolated and unlikely to introduce another bug. ## Verification - [X] Manual (required) - [ ] Automated ## Packaging changes reviewed? - [ ] Yes - [ ] No - [X] N/A
1 parent c9e66ca commit fe4f0d0

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/Components/Web.JS/dist/Release/blazor.webview.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/src/Boot.WebView.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ async function boot(): Promise<void> {
2020
}
2121
started = true;
2222

23-
const jsInitializer = await fetchAndInvokeInitializers();
24-
25-
startIpcReceiver();
26-
2723
dispatcher = DotNet.attachDispatcher({
2824
beginInvokeDotNetFromJS: sendBeginInvokeDotNetFromJS,
2925
endInvokeJSFromDotNet: sendEndInvokeJSFromDotNet,
3026
sendByteArray: sendByteArray,
3127
});
3228

29+
const jsInitializer = await fetchAndInvokeInitializers();
30+
31+
startIpcReceiver();
32+
3333
Blazor._internal.receiveWebViewDotNetDataStream = receiveWebViewDotNetDataStream;
3434

3535
navigationManagerFunctions.enableNavigationInterception();

src/Components/Web.JS/src/Platform/WebView/WebViewIpcReceiver.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ export function startIpcReceiver(): void {
3333
showErrorNotification();
3434
},
3535

36-
'BeginInvokeJS': dispatcher.beginInvokeJSFromDotNet,
36+
'BeginInvokeJS': dispatcher.beginInvokeJSFromDotNet.bind(dispatcher),
3737

38-
'EndInvokeDotNet': dispatcher.endInvokeDotNetFromJS,
38+
'EndInvokeDotNet': dispatcher.endInvokeDotNetFromJS.bind(dispatcher),
3939

4040
'SendByteArrayToJS': receiveBase64ByteArray,
4141

0 commit comments

Comments
 (0)