-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[browser] mono_exit improvements #88387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
021af3f
wip
pavelsavara 362de7d
wip
pavelsavara 6868135
fix MT
pavelsavara 82faafd
Merge branch 'main' into browser_exit
pavelsavara 0ff8506
don't call managed from finalizer after exit
pavelsavara 1fa9423
Merge branch 'main' into browser_exit
lewing eb35a3a
wip
pavelsavara dc9c91d
Merge branch 'browser_exit' of https://github.com/pavelsavara/runtime…
pavelsavara 6098948
Merge branch 'main' into browser_exit
pavelsavara 1fbef45
fix
pavelsavara 30f4759
wip
pavelsavara 9ff8180
wip
pavelsavara 7369de8
wip
pavelsavara 4bd12cc
wip
pavelsavara 1994535
fix
pavelsavara ecba64c
Merge branch 'main' into browser_exit
pavelsavara f48febe
Merge branch 'main' into browser_exit
pavelsavara 85097f0
feedback from @kg
pavelsavara a1dde14
fix
pavelsavara fdf18bd
Merge branch 'main' into browser_exit
pavelsavara b246a3c
bad merge
pavelsavara f93a43d
fix abort
pavelsavara 1818f02
Merge branch 'main' into browser_exit
pavelsavara c5e0c48
Merge branch 'main' into browser_exit
pavelsavara 66bfa87
fixx merge
pavelsavara 5c0faf0
fix abort + sample
pavelsavara fbbdfc7
fix
pavelsavara 8b43077
@maraf's feedback about just one exit method
pavelsavara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| TOP=../../../../.. | ||
|
|
||
| include ../wasm.mk | ||
|
|
||
| ifneq ($(AOT),) | ||
| override MSBUILD_ARGS+=/p:RunAOTCompilation=true | ||
| endif | ||
|
|
||
| PROJECT_NAME=Wasm.Browser.Shutdown.Sample.csproj | ||
|
|
||
| run: run-browser |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Runtime.InteropServices.JavaScript; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| namespace Sample | ||
| { | ||
| public partial class Test | ||
| { | ||
| public static int Main(string[] args) | ||
| { | ||
| return 0; | ||
| } | ||
|
|
||
| [JSExport()] | ||
| public static void DoNothing () | ||
| { | ||
| Console.WriteLine("You got it, boss! Doing nothing!"); | ||
| } | ||
|
|
||
| [JSExport()] | ||
| public static void ThrowManagedException () | ||
| { | ||
| throw new Exception("I'll make an exception to the rules just this once... and throw one."); | ||
| } | ||
|
|
||
| [JSExport()] | ||
| public static void CallFailFast () | ||
| { | ||
| System.Environment.FailFast("User requested FailFast"); | ||
| } | ||
|
|
||
| [JSImport("timerTick", "main.js")] | ||
| public static partial void TimerTick (int i); | ||
|
|
||
| [JSExport()] | ||
| public static void StartTimer () | ||
| { | ||
| int i = 0; | ||
| var timer = new System.Timers.Timer(1000); | ||
| timer.Elapsed += (s, e) => { | ||
| TimerTick(i); | ||
| i += 1; | ||
| }; | ||
| timer.AutoReset = true; | ||
| timer.Enabled = true; | ||
| } | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/mono/sample/wasm/browser-shutdown/Wasm.Browser.Shutdown.Sample.csproj
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <Import Project="..\DefaultBrowserSample.targets" /> | ||
| <ItemGroup> | ||
| <WasmExtraFilesToDeploy Include="main.js" /> | ||
| </ItemGroup> | ||
| </Project> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <!DOCTYPE html> | ||
| <!-- Licensed to the .NET Foundation under one or more agreements. --> | ||
| <!-- The .NET Foundation licenses this file to you under the MIT license. --> | ||
| <html> | ||
|
|
||
| <head> | ||
| <title>Wasm Browser Shutdown Sample</title> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <script type='module' src="./main.js"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <h3 id="header">Wasm Browser Shutdown Sample</h3> | ||
| <button id="throw-managed-exc">Throw Managed Exception</button> | ||
| <button id="trigger-native-assert">Trigger Native Assert</button> | ||
| <button id="trigger-failfast">Trigger Environment.FailFast</button> | ||
| <button id="call-jsexport">Call Harmless JSExport</button> | ||
| <button id="call-exit">Call exit</button> | ||
| <button id="start-timer">Start Timer</button><br> | ||
| Timer Value: <span id="timer-value"></span> | ||
| </body> | ||
|
|
||
| </html> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| import { dotnet, exit } from './_framework/dotnet.js' | ||
|
|
||
| let exports = undefined, | ||
| setenv = undefined; | ||
|
|
||
| window.addEventListener("load", onLoad); | ||
|
|
||
| try { | ||
| const { setModuleImports, getAssemblyExports, setEnvironmentVariable, getConfig } = await dotnet | ||
| .withModuleConfig() | ||
| .withExitOnUnhandledError() | ||
| .withExitCodeLogging() | ||
| .withElementOnExit() | ||
| .withAssertAfterExit() | ||
| .withOnConfigLoaded(() => { | ||
| // you can test abort of the startup by opening http://localhost:8000/?throwError=true | ||
| const params = new URLSearchParams(location.search); | ||
| if (params.get("throwError") === "true") { | ||
| throw new Error("Error thrown from OnConfigLoaded"); | ||
| } | ||
| }) | ||
| .create(); | ||
|
|
||
| setModuleImports("main.js", { | ||
| timerTick: (i) => { | ||
| document.querySelector("#timer-value").textContent = i; | ||
| }, | ||
| }); | ||
|
|
||
| setenv = setEnvironmentVariable; | ||
| const config = getConfig(); | ||
| exports = await getAssemblyExports(config.mainAssemblyName); | ||
| } | ||
| catch (err) { | ||
| exit(2, err); | ||
| } | ||
|
|
||
| function onLoad() { | ||
| document.querySelector("#throw-managed-exc").addEventListener("click", () => { | ||
| try { | ||
| exports.Sample.Test.ThrowManagedException(); | ||
| alert("No JS exception was thrown!"); | ||
| } catch (exc) { | ||
| alert(exc); | ||
| } | ||
| }); | ||
| document.querySelector("#trigger-failfast").addEventListener("click", () => { | ||
| try { | ||
| exports.Sample.Test.CallFailFast(); | ||
| alert("No JS exception was thrown!"); | ||
| } catch (exc) { | ||
| alert(exc); | ||
| } | ||
| }); | ||
| document.querySelector("#start-timer").addEventListener("click", () => { | ||
| try { | ||
| exports.Sample.Test.StartTimer(); | ||
| } catch (exc) { | ||
| alert(exc); | ||
| } | ||
| }); | ||
| document.querySelector("#trigger-native-assert").addEventListener("click", () => { | ||
| try { | ||
| setenv(null, null); | ||
| alert("No JS exception was thrown!"); | ||
| } catch (exc) { | ||
| alert(exc); | ||
| } | ||
| }); | ||
| document.querySelector("#call-jsexport").addEventListener("click", () => { | ||
| try { | ||
| exports.Sample.Test.DoNothing(); | ||
| } catch (exc) { | ||
| alert(exc); | ||
| } | ||
| }); | ||
| document.querySelector("#call-exit").addEventListener("click", () => { | ||
| try { | ||
| exit(7, "User clicked exit"); | ||
| } catch (exc) { | ||
| alert(exc); | ||
| } | ||
| }); | ||
| } |
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
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
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
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
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
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
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
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
1 change: 1 addition & 0 deletions
1
src/mono/wasm/runtime/diagnostics/server_pthread/ipc-protocol/serializer.ts
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.