Comments (6)
@nocelab can you share the code? I didnt notice anything like that when testing.
from hbrowser.
this is sample code (Windows 10 with OpenJDK 8u222-b10):
HBrowser hBrowser = new HBrowser();
PlaywrightWindow hb = hBrowser.openCustomWindow().headless(false).buildPlaywrightWindow();
for (int i = 0; i < 100; i++) {
hb.load("www.google.it");
hb.fill("[aria-label=\"Cerca\"]", "searching something");
hb.holdKey("Tab");
// click and wait...
hb.getJsContext().executeJavaScript(""+
"await Promise.all([\n"+
" page.click(':nth-match(:text(\"Cerca con Google\"), 2)'),\n"+
" page.waitForNavigation()\n"+
"]);");
System.out.println(hb.getOuterHtml().text());
}
hb.close();
and this is memory graph of node.exe process:
from hbrowser.
Ok I tested this code first just to make sure node was working fine by default:
HBrowser hBrowser = new HBrowser();
try(PlaywrightWindow window = hBrowser.openWindow()){
window.load("www.google.com");
System.out.println("Loaded page! Exit the program once finished with ram analysis...");
while (true)
Thread.sleep(1000);
} catch (NodeJsCodeException | InterruptedException e) {
e.printStackTrace();
}
And it looks good since the node.exe uses only a steady amount of 31mb.
Then I tested your code (slightly modified):
HBrowser hBrowser = new HBrowser();
try(PlaywrightWindow window = hBrowser.openCustomWindow().headless(false).buildPlaywrightWindow()){
for (int i = 0; i < 100; i++) {
window.load("www.google.it");
window.fill("[aria-label=\"Cerca\"]", "searching something");
window.holdKey("Tab");
// click and wait...
window.getJsContext().executeJavaScript(""+
"await Promise.all([\n"+
" page.click(':nth-match(:text(\"Cerca con Google\"), 2)'),\n"+
" page.waitForNavigation()\n"+
"]);");
System.out.println("Run: "+i);
}
} catch (NodeJsCodeException e) {
e.printStackTrace();
}
Your code throws following exception:
com.osiris.headlessbrowser.exceptions.NodeJsCodeException: Error during JavaScript code execution! Details:
CAUGHT JS-EXCEPTION: TimeoutError
MESSAGE: page.fill: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "[aria-label="Cerca"]"
============================================================
LINE: undefined
STACK: page.fill: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "[aria-label="Cerca"]"
============================================================
at REPL12:2:12
at REPL12:8:4
at com.osiris.headlessbrowser.js.contexts.NodeContext.executeJavaScript(NodeContext.java:383)
at com.osiris.headlessbrowser.js.contexts.NodeContext.executeJavaScript(NodeContext.java:304)
at com.osiris.headlessbrowser.windows.PlaywrightWindow.fill(PlaywrightWindow.java:711)
at com.osiris.headlessbrowser.windows.PlaywrightWindow.fill(PlaywrightWindow.java:681)
at com.osiris.headlessbrowser.issues.Issue9.main(Issue9.java:13)
Process finished with exit code 0
Thus I wasn't able to see the same increase in memory as you since it aborts. Maybe the missing try/catch was somehow your issue?
from hbrowser.
In my sample nothing goes in exception.
You have to adapt my code with your google.com right localized labels... this graph with your try/catch code:
from hbrowser.
Yeah was able to run your code successfully with the same results.
Looked at the java and js code of headless browser and there don't seem to be memory leaks.
I guess its playwright storing the previously loaded pages to allow back and forth navigation.
from hbrowser.
Ok... I'am happy!
You are right, perhaps something like microsoft/playwright#6319.
I will deepen with Playwright... thanks!
from hbrowser.
Related Issues (13)
- Two suggestions: screenshots, and table-of-features HOT 1
- .dyml files saved on windows produce wrong values because of \r\n
- .dyml value contains space at beginning
- Cause: java.io.IOException: Stream closed (in NodeContext)
- java.lang.RuntimeException: java.io.IOException: Stream closed HOT 2
- Wrong arch detection - node: cannot execute binary file error HOT 3
- GraalWindow: Implement the DOM-API HOT 1
- Fix NodeJs issues
- Fix error on NodeWindow close
- Make headless undetectable with xvfb HOT 1
- java.lang.RuntimeException: java.lang.Exception: node.exe couldn't be found in HOT 8
- Click with promise.All HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hbrowser.