Skip to content
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

[Feature] Any plans to adapt to net8's AOT #2714

Open
hzexe opened this issue Sep 30, 2023 · 17 comments
Open

[Feature] Any plans to adapt to net8's AOT #2714

hzexe opened this issue Sep 30, 2023 · 17 comments

Comments

@hzexe
Copy link

hzexe commented Sep 30, 2023

Let us know what functionality you'd like to see in Playwright and what your use case is.
Do you think others might benefit from this as well?
Might benefit:

  1. run faster first time,and save start time
  2. smaller docker image size
  3. better code protection
@mxschmitt
Copy link
Member

This seems not compatible with Playwrights architecture, since the expenzsivest part happens inside the browser or do you want to compile your app with AOT instead and our Library prevents you from doing that?

@mxschmitt mxschmitt closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2023
@hzexe
Copy link
Author

hzexe commented Oct 19, 2023

Json serialization and deserialization , which does not work in.NET full AOT

@mxschmitt
Copy link
Member

Can you provide us a repro in form of a repository of whats not working?

@NCLnclNCL
Copy link

Json serialization and deserialization , which does not work in.NET full AOT

Use selenium

@NCLnclNCL
Copy link

Can you provide us a repro in form of a repository of whats not working?

It is bad

@mxschmitt
Copy link
Member

I can repro after setting:

<PropertyGroup>
  <PublishAot>true</PublishAot>
</PropertyGroup>

on a new console project as per here and it produces:

❯ ./bin/Release/net8.0/osx-arm64/aot-test 
Unhandled exception. System.InvalidOperationException: Reflection-based serialization has been disabled for this application. Either use the source generator APIs or explicitly configure the 'JsonSerializerOptions.TypeInfoResolver' property.
   at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_JsonSerializerIsReflectionDisabled()
   at System.Text.Json.JsonSerializerOptions.ConfigureForJsonSerializer()
   at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions options, Type inputType)
   at System.Text.Json.JsonSerializer.GetTypeInfo[T](JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.SerializeToUtf8Bytes[TValue](TValue value, JsonSerializerOptions options)
   at Microsoft.Playwright.Playwright.<>c__DisplayClass0_0.<CreateAsync>b__3(Object message, Boolean keepNulls) in /_/src/Playwright/Playwright.cs:line 55
   at Microsoft.Playwright.Transport.Connection.<>c__DisplayClass40_0`1.<InnerSendMessageToServerAsync>b__4() in /_/src/Playwright/Transport/Connection.cs:line 206
   at Microsoft.Playwright.Helpers.TaskQueue.EnqueueAsync(Func`1 taskGenerator) in /_/src/Playwright/Helpers/TaskQueue.cs:line 49
   at Microsoft.Playwright.Transport.Connection.InnerSendMessageToServerAsync[T](ChannelOwnerBase object, String method, Dictionary`2 dictionary, Boolean keepNulls) in /_/src/Playwright/Transport/Connection.cs:line 193
   at Microsoft.Playwright.Transport.Connection.WrapApiCallAsync[T](Func`1 action, Boolean isInternal) in /_/src/Playwright/Transport/Connection.cs:line 535
   at Microsoft.Playwright.Transport.Channels.Root.InitializeAsync() in /_/src/Playwright/Transport/Channels/Root.cs:line 45
   at Microsoft.Playwright.Playwright.CreateAsync() in /_/src/Playwright/Playwright.cs:line 57
   at Program.<Main>$(String[] args) in /Users/maxschmitt/Developer/tmp/aot-test/Program.cs:line 3
   at Program.<Main>(String[] args)
[1]    62788 abort      ./bin/Release/net8.0/osx-arm64/aot-test

@nohwnd
Copy link
Member

nohwnd commented Mar 27, 2024

I don't think it makes sense adding nativeaot to playwright.net (at least not yet). Playwright.net is a layer over the engine that run in node, and where most of the interesting stuff happens. Setting PublishAOT and actually publishing to native executable are two very different things. With the latter being blocked by:

  • NUnit & XUnit not compatible with NativeAOT.
  • MSTest only supporting a subset of functionality in NativeAOT mode.
  • The native build time is long enough to offset the savings in test runs.
  • There is no support in VS to publish and run tests from native.

@chenrensong
Copy link

you can try PuppeteerAot ,this library is support for aot

@NCLnclNCL
Copy link

bạn có thể thử PuppeteerAot , thư viện này hỗ trợ cho aot

thanks

@NCLnclNCL
Copy link

chenrensong
Can you convert NewtonSoft.Json to System.Text.Json for selenium?

@chenrensong
Copy link

chenrensong
Can you convert NewtonSoft.Json to System.Text.Json for selenium?

Can you provide selenium project url?

@NCLnclNCL
Copy link

chenrensong
Can you convert NewtonSoft.Json to System.Text.Json for selenium?

Can you provide selenium project url?

https://github.com/SeleniumHQ/selenium/tree/trunk/dotnet

@RenderMichael
Copy link
Contributor

RenderMichael commented Apr 16, 2024

  • NUnit & XUnit not compatible with NativeAOT.
  • MSTest only supporting a subset of functionality in NativeAOT mode.
  • The native build time is long enough to offset the savings in test runs.
  • There is no support in VS to publish and run tests from native.

Most of these issues are being actively worked on: https://devblogs.microsoft.com/dotnet/introducing-ms-test-runner/

microsoft/testfx#2164

@nohwnd
Copy link
Member

nohwnd commented Apr 16, 2024

@chenrensong Can you please help me understand why you want / need NativeAOT for web testing? What are the benefits we could see in Playwright, when most of the work is offloaded to node.js. Maybe I am missing something here :)

@RenderMichael
Copy link
Contributor

Making the library trim-compatible is good future-proofing hygiene, and ensures consumers know which methods aren't trim- or AOT-safe.

Would the maintainers accept PRs annotating the Playwright libraries for trimming and AOT?

@slang25
Copy link
Contributor

slang25 commented Apr 16, 2024

This might be my memory playing tricks on me, but when I first used Playwright many moons ago, I was under the impression that it was a more general purpose browser automation, which obviously ideal for testing web apps, but would also be a good fit for the puppeteer use-cases. For example generating images from web assets, turning HTLM into PDFs as part of an invoicing platform, etc...

Today it's very clear on the Playwright website that this is a web testing library, in which case I agree it doesn't make practical sense to make it AOT friendly.

@chenrensong
Copy link

@chenrensong Can you please help me understand why you want / need NativeAOT for web testing? What are the benefits we could see in Playwright, when most of the work is offloaded to node.js. Maybe I am missing something here :)

The. net version of Puppeter or Playwright essentially implements network testing by calling the browser kernel. The purpose of AOT execution is because currently developing Maui Mac version applications or Avalonia applications that wish to use AOT for compilation when released, and if these libraries are used, errors will be reported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants