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

423 disable js engine #424

Merged
merged 11 commits into from
Oct 18, 2023
Merged

423 disable js engine #424

merged 11 commits into from
Oct 18, 2023

Conversation

rschwietzke
Copy link
Contributor

JS engine is off by default and not started. A short test has shown that the scripts for regular load tests still work. We are also not creating the debugger object, if not needed.

CPU

-10 %

Old

image

New

image

Memory

-200 MB

Old

image

New

image

@rschwietzke rschwietzke linked an issue Oct 6, 2023 that may be closed by this pull request
@rbri
Copy link

rbri commented Oct 9, 2023

cool

@rschwietzke rschwietzke added enhancement New feature or request performance labels Oct 9, 2023
Copy link
Contributor

@jowerner jowerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XltWebClient always sets an XltJavaScriptEngine instance at the moment. To save even more resources, this should be skipped if javaScriptEngineEnabled is false.

When loading static content, the XltWebClient relies on the Javascript engine being available in order to evaluate CSS styles, etc. This functionality of XltWebClient needs to be bypassed when javaScriptEngineEnabled is false.

Also it seems that we should rather replace most occurrences of WebClient.getOptions().isJavaScriptEnabled() with WebClient.isJavaScriptEnabled() as the latter also takes the javaScriptEngineEnabled flag into account.

@rbri
Copy link

rbri commented Oct 10, 2023

When loading static content, the XltWebClient relies on the Javascript engine being available in order to evaluate CSS styles, etc. This functionality of XltWebClient needs to be bypassed when javaScriptEngineEnabled is false.

This is something still on my list - maybe i can give it another try to finally fix this

Also it seems that we should rather replace most occurrences of WebClient.getOptions().isJavaScriptEnabled() with WebClient.isJavaScriptEnabled() as the latter also takes the javaScriptEngineEnabled flag into account.

Sounds correct for me

@rbri
Copy link

rbri commented Oct 15, 2023

When loading static content, the XltWebClient relies on the Javascript engine being available in order to evaluate CSS styles, etc.

I guess this is now fixed. Do you have some time to test this?

@rbri
Copy link

rbri commented Oct 15, 2023

just made a new snapshot build...

…o when JS is off

* first XltWebClient tweaks
* adjusted various test cases to enable JS engine/JS where needed
// check all style sheets
final StyleSheetList sheets = document.getStyleSheets();
for (int i = 0; i < sheets.getLength(); i++)
if (isJavaScriptEnabled())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with 3.7 js support is no longer required to work with style sheets.

At least for this you can hopefully use HtmlPage.getStyleSheets() HtmlUnit/htmlunit@03877bb.
Will try to make a new snapshot later today.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! When time permits, we will upgrade to 3.7 and see what we can simplify on our end.