Repository navigation
Release 1.1.1 - #20
Merged
Merged
Conversation
- Mark the net8.0 and net10.0 targets IsAotCompatible, so the trim and AOT analyzers run on every build, with the same KnownILLinkPack override as AngleSharp, AngleSharp.Xml, AngleSharp.Css and AngleSharp.Io - Update AGENTS.md and CHANGELOG.md No code changes were needed: both targets build without trim or AOT warnings, and a console app published with PublishAot (runtime API, DOM bridge, host imports, CompileError) compiles without warnings, Wasmtime included, and runs correctly.
The switch expression in ConvertArguments had int, long, float and double arms, so C# gave it the common type double: every argument reached the import callback as a boxed double, and i64 values above 2^53 lost precision. Box each arm as object instead, so i32, i64, f32 and f64 arrive as int, long, float and double.
WebAssembly from a page could grow its memory to 4 GiB and run an endless loop that nothing can interrupt. WasmtimeWasmRuntimeOptions adds three opt-in limits, all off by default so existing behavior is unchanged: - MaximumMemorySize and MaximumTableElements, applied with Store.SetLimits to every instance's store - Fuel, a per-call budget refilled when the host calls into an instance (and before instantiation, for the start function); calls a host import makes back into the same instance share the outer budget, so they cannot reset it The options are accepted by WasmtimeWasmRuntime, WasmtimeWasmRuntimeFactory and a new WithWasm(WasmtimeWasmRuntimeOptions) overload. A failed instantiation now disposes its store right away.
Make the library trim and Native AOT compatible
Pass host import arguments with their WebAssembly types
WasmtimeStoreContext.Run takes the state as a parameter, so every call site uses a static lambda and the default (no limits) path allocates nothing extra per call. Measured with BenchmarkDotNet against devel: per-call allocation is identical, time within 0-2.4%.
The options hold no Wasmtime types and the limits apply to any runtime, so the name stays independent of the Wasmtime implementation, as suggested in the review.
Add optional memory, table and fuel limits to the Wasmtime runtime
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Types of Changes
Prerequisites
Please make sure you can check the following two boxes:
Contribution Type
What types of changes does your code introduce? Put an
xin all the boxes that apply:Description
This pull request introduces a new resource-limiting feature for the WebAssembly runtime in
AngleSharp.Wasm, adds comprehensive tests for these limits, fixes a type issue with host import arguments, and updates documentation and build infrastructure to support trimming and Native AOT compatibility. The main themes are improved runtime security and compatibility, enhanced testing, and CI workflow updates.