Re-enable Release AOT by excluding only OpenCvSharp.dll - #9
Conversation
…ot-cross crash Shadows the SDK's internal _WasmAotCompileApp target to remove OpenCvSharp.dll from the AOT input list, then re-adds it to the app's assembly set afterward so it still ships (as plain IL, interpreted at runtime instead of AOT-compiled). If this works, the rest of the app gets full AOT while sidestepping the crash entirely - not waiting on an upstream dotnet/runtime fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The partial-AOT exclusion experiment confirmed: 38 assemblies AOT-compile successfully, OpenCvSharp.dll still ships as plain IL (verified in the published output), no mono-aot-cross crash. Full app now gets AOT'd except this one assembly, sidestepping the crash without waiting on an upstream dotnet/runtime fix. Temporarily add this branch to deploy-pages.yml's push trigger to verify the full deploy pipeline end-to-end with AOT back on; will drop before merging. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
build succeeded on this branch (run 29157608898) with RunAOTCompilation back on and OpenCvSharp.dll excluded; deploy only failed due to the github-pages environment's main-only protection rule, as expected. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughRelease builds now enable WebAssembly AOT compilation. MSBuild temporarily removes ChangesAOT handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
BlazorApp/BlazorApp.csproj (1)
81-87: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAdd a warning when OpenCvSharp is not found in the AOT assembly list.
If a future SDK update renames
_WasmAssembliesInternalor changes its item metadata,_OpenCvSharpAssemblyToSkipAOTwould be empty. TheMessageon line 86 would print "Excluding from AOT: " (nothing after the colon), which looks like success but means the workaround is silently inactive — OpenCvSharp would then be AOT'd and crashmono-aot-cross. Adding a conditional warning when the captured item is empty makes this failure mode loud instead of silent.
⚠️ Proposed fix: warn when the item is empty<Target Name="ExcludeOpenCvSharpFromAOT" BeforeTargets="_WasmAotCompileApp" Condition="'$(_WasmShouldAOT)' == 'true'"> <ItemGroup> <_OpenCvSharpAssemblyToSkipAOT Include="@(_WasmAssembliesInternal)" Condition="'%(FileName)' == 'OpenCvSharp'" /> <_WasmAssembliesInternal Remove="@(_OpenCvSharpAssemblyToSkipAOT)" /> </ItemGroup> - <Message Importance="High" Text="Excluding from AOT: @(_OpenCvSharpAssemblyToSkipAOT)" /> + <Message Importance="High" Text="Excluding from AOT: @(_OpenCvSharpAssemblyToSkipAOT)" Condition="'@(_OpenCvSharpAssemblyToSkipAOT)' != ''" /> + <Warning Text="OpenCvSharp was not found in _WasmAssembliesInternal — the AOT exclusion workaround may be inactive. Check if the SDK changed the internal item name/metadata." Condition="'@(_OpenCvSharpAssemblyToSkipAOT)' == ''" /> </Target>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@BlazorApp/BlazorApp.csproj` around lines 81 - 87, Update the ExcludeOpenCvSharpFromAOT target to emit a warning when _OpenCvSharpAssemblyToSkipAOT is empty, while preserving the existing high-importance exclusion message and removal behavior when OpenCvSharp is found. Use a condition on the warning so the inactive workaround is reported clearly without adding an unconditional warning.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@BlazorApp/BlazorApp.csproj`:
- Around line 81-87: Update the ExcludeOpenCvSharpFromAOT target to emit a
warning when _OpenCvSharpAssemblyToSkipAOT is empty, while preserving the
existing high-importance exclusion message and removal behavior when OpenCvSharp
is found. Use a condition on the warning so the inactive workaround is reported
clearly without adding an unconditional warning.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6fc83de0-4571-407a-aa98-5849055eae72
📒 Files selected for processing (1)
BlazorApp/BlazorApp.csproj
…cvsharp Re-enable Release AOT by excluding only OpenCvSharp.dll
Summary
mono-aot-crosswhile precompilingOpenCvSharp.dll(native GC assertion,sgen-alloc.c:409) — see shimat/opencvsharp_blazor_sample#8. A minimal repro isolated the trigger toOpenCvSharp.dll's own P/Invoke surface (~3100LibraryImportdeclarations), not native lib size orNativeFileReferencein general — a tiny test app referencing the same large native.abut only 3 fakeLibraryImportmethods AOT-compiled fine._WasmAotCompileApptarget to exclude justOpenCvSharp.dllfrom the AOT set (it still ships as plain IL, executed by the interpreter at runtime) while the rest of the app gets full AOT.RunAOTCompilationis back totrue(default) for Release — wasfalsesince Add GitHub Pages deploy workflow #7, as a stopgap while full AOT was completely broken.Test plan
dotnet publish -c Release -p:RunAOTCompilation=truesucceeds: "AOT'ing 38 assemblies" completes with no crash — https://github.com/shimat/opencvsharp_blazor_sample/actions/runs/29156433420OpenCvSharp.<hash>.wasmis still present in the published_frameworkoutput (not silently dropped)deploy-pages.ymlpipeline (publish + Pages artifact) succeeds end-to-end with AOT back on — https://github.com/shimat/opencvsharp_blazor_sample/actions/runs/29157608898 (thedeployjob there only failed due to thegithub-pagesenvironment's main-only protection rule, expected on a feature branch)Caveat
This shadows an internal, undocumented SDK target (
_WasmAotCompileApp) by name — its shape may change in a future wasm-tools workload update. If a future SDK bump breaks this (build error, or the exclusion silently stops working), fall back to<RunAOTCompilation>False</RunAOTCompilation>for Release as before.🤖 Generated with Claude Code
Summary by CodeRabbit