While using the WebEngine
in JavaFX2, I've noticed it sometimes just gets stuck. Assume I were making a crawler that simply finds hyperlinks on a page and then visits them to do the same recursively, keeping track of which links we have visited and which are already on the frontier. While running my code, the execution would sometimes hang at arbitrary moments.
I've added some debug code to my project in the form of listeners to the workDoneProperty
and exceptionProperty
and by printing every transition of the loadWorker
's stateProperty
. Then I noticed sometimes the engine would stop mid-loading of a URL (the state is stuck in RUNNING
and there are no more workDone
updates). I'm assuming this is because of a time out or something, but I've stopped waiting to see if it is indeed a timeout after 5 minutes.
The exceptionProperty
doesn't seem to generate any events nor does the webEngine
transition into FAILED
or CANCELLED
, it just stops. I'm wondering if this is potentially a race condition in the library or maybe there's something I'm missing... Has anyone encountered this who knows how this can be fixed? It's quite important for my app that the engine doesn't just stop randomnly...
EDIT: added output from my console:
Work done: -1
Engine Load Worker transitioning into state: READY
Work done: 0
Engine Load Worker transitioning into state: SCHEDULED
Engine Load Worker transitioning into state: RUNNING
Work done: 21
Work done: 24
Work done: 24
Work done: 57
Work done: 72
BUILD STOPPED (total time: 9 minutes 32 seconds)