-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
NrbfReader tests not working in WASM/mobile #104142
Comments
Tagging subscribers to this area: @dotnet/area-system-runtime |
mscorlib is available for these platforms. I think that the problem that you are seeing is that these tests have trimming enabled when running on mobile/WASM, but binary serialization is incompatible with trimming. The trimming strips mscorlib since it does not see it used anywhere. I expect that you would see similar problems if you enabled these tests e.g. on native AOT on any platforms. |
@adamsitnik @bartonjs If I'm understanding the failing stack trace correctly, it is not product code from Assuming |
That is correct. IMO we should make sure that these tests are disabled on WASM/Mobile but also change the new OOB package to throw |
Unless I'm missing something the detection logic already excludes these platforms: runtime/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs Lines 734 to 737 in 0f2ce10
cc @dotnet/dotnet-webassembly-admin |
It does. But I am not sure if the line that follows this
@eiriktsarpalis I may be paranoid here and it may be working as expected, just sharing my thoughts here. |
runtime/src/libraries/tests.proj Lines 437 to 440 in c4624d0
|
I think I misunderstood the issue. It's not that it's failing in CI but rather it was failing when you were working on the tests and you then got disabled in ec45dad. I don't think there is much that we can do for .NET 9. In the future can try to enable the tests in those platforms by precomputing the BF blobs ahead of time. |
|
Ok, so you're saying that issue is with the |
Tagging subscribers to 'binaryformatter-migration': @adamsitnik, @bartonjs, @jeffhandley, @terrajobst |
You will get this behavior anywhere trimming is enabled. It is not specific to WASM. You will see it even with e.g. regular CoreCLR when you enable trimming.
These is nothing fundamental preventing the binary formatter OOB package from working on WASM (if you disable trimming). The app will be big, but it should work.
This behavior was introduced when we were chipping on the binary formatter without understanding the desired state. I do not think it makes sense to keep it. |
I see the BF APIs are already annotated RUC/RDC as well so I think this type of error is par for the course. We could try improving the error message for that particular failure but then other runtime errors related to trimming would pop up elsewhere. STJ has similar behaviour in this context. cc @bartonjs for a third opinion |
Not by going back to dual-compile. That was an easy pill to swallow for inbox, but it's a pretty big cost to increase the package size to make one "doesn't work" turn into another. That said, changing PNSE into TypeInitializationException is a breaking change... so we should make a best-effort at fixing it (and if we can't, then doc it as a breaking change) |
It is not a breaking change in this case. We make no guarantees about behavior of trim-incompatible APIs in trimmed apps. The trim-incompatible APIs can do anything. The API behavior can even change due to unrelated changes in the app. It is by design. |
From what I understand this situation is as follows:
If that's correct then I agree with @jkotas and @eiriktsarpalis: since |
Nit - I think that the situation is as follows:
|
Fair enough. I think it doesn't change my conclusion -- still feels fine to me. |
Sounds good. I'll leave this issue open to track potentially making the NrbfReader tests work in these platforms using precomputed blobs. |
In #104104 I've tried to re-enable all BF tests and got following error for WASM/Mobile builds:
Most likely it's trying to load "mscorlib" which is not available for these platforms:
runtime/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/Converter.cs
Line 38 in d6f4bee
Prior to #103255 BF would simply throw
PNSE
for them:runtime/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj
Line 3 in a82225e
runtime/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj
Lines 77 to 79 in a82225e
@bartonjs should we change the OOB package to keep throwing PNSE for WASM/Mobile?
The text was updated successfully, but these errors were encountered: