Skip to content

Commit

Permalink
[release/8.0-preview5] [Blazor] Fix WebView JavaScript boot bug (#48594)
Browse files Browse the repository at this point in the history
# [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
  • Loading branch information
MackinnonBuck authored Jun 3, 2023
1 parent c9e66ca commit fe4f0d0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Components/Web.JS/dist/Release/blazor.webview.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/Components/Web.JS/src/Boot.WebView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ async function boot(): Promise<void> {
}
started = true;

const jsInitializer = await fetchAndInvokeInitializers();

startIpcReceiver();

dispatcher = DotNet.attachDispatcher({
beginInvokeDotNetFromJS: sendBeginInvokeDotNetFromJS,
endInvokeJSFromDotNet: sendEndInvokeJSFromDotNet,
sendByteArray: sendByteArray,
});

const jsInitializer = await fetchAndInvokeInitializers();

startIpcReceiver();

Blazor._internal.receiveWebViewDotNetDataStream = receiveWebViewDotNetDataStream;

navigationManagerFunctions.enableNavigationInterception();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export function startIpcReceiver(): void {
showErrorNotification();
},

'BeginInvokeJS': dispatcher.beginInvokeJSFromDotNet,
'BeginInvokeJS': dispatcher.beginInvokeJSFromDotNet.bind(dispatcher),

'EndInvokeDotNet': dispatcher.endInvokeDotNetFromJS,
'EndInvokeDotNet': dispatcher.endInvokeDotNetFromJS.bind(dispatcher),

'SendByteArrayToJS': receiveBase64ByteArray,

Expand Down

0 comments on commit fe4f0d0

Please sign in to comment.