Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Java applications using JavaFX WebView eventually freeze #645

Open
jmborer opened this issue Jan 20, 2021 · 6 comments
Open

Java applications using JavaFX WebView eventually freeze #645

jmborer opened this issue Jan 20, 2021 · 6 comments

Comments

@jmborer
Copy link

jmborer commented Jan 20, 2021

We are running into a very nasty issue: Java application either Swing or pure JavaFX that use the WebView eventually freeze. This happens randomly, but this occurs always. Impossible to leave an application with WebView running during a long time.

It occurs with Java 8 on Win10 (we cannot use the other versions or platforms):

  • Oracle JRE 1.8 271
  • zulu8.50.0.53-ca-fx-jre8.0.275-win_x64

To reproduce, compile the app below, browse pages, switch between applications and leave it running in the background. It will eventually freeze (can be a few minutes, or hours or days), but it will freeze. No memory issue AFAIK.

package org.test.webview;

import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.geometry.VPos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.paint.Color;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebViewApp extends Application {

    private Scene scene;

    @Override
    public void start(Stage stage) {
        // create the scene
        stage.setTitle("Web View");
        scene = new Scene(new FxBrowser(), 750, 500, Color.web("#666970"));
        stage.setScene(scene);
        scene.getStylesheets().add("webviewsample/BrowserToolbar.css");
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

class FxBrowser extends Region {

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    public FxBrowser() {
        //apply the styles
        getStyleClass().add("browser");
        // load the web page
        webEngine.load("http://172.20.185.184:3000");
        //add the web view to the scene
        getChildren().add(browser);
    }

    private Node createSpacer() {
        Region spacer = new Region();
        HBox.setHgrow(spacer, Priority.ALWAYS);
        return spacer;
    }

    @Override
    protected void layoutChildren() {
        double w = getWidth();
        double h = getHeight();
        layoutInArea(browser, 0, 0, w, h, 0, HPos.CENTER, VPos.CENTER);
    }

    @Override
    protected double computePrefWidth(double height) {
        return 750;
    }

    @Override
    protected double computePrefHeight(double width) {
        return 500;
    }
}

Once frozen, we forced a win dump with WinDbg and inspected the dump:


0:000> !locks

CritSec ntdll!LdrpLoaderLock+0 at 00007ff89a31f4f8
WaiterWoken        No
LockCount          1
RecursionCount     1
OwningThread       2d14
EntryCount         0
ContentionCount    1
*** Locked

Scanned 18 critical sections
0:000> !cs -l
-----------------------------------------
DebugInfo          = 0x00007ff89a31f978
Critical section   = 0x00007ff89a31f4f8 (ntdll!LdrpLoaderLock+0x0)
LOCKED
LockCount          = 0x1
WaiterWoken        = No
OwningThread       = 0x0000000000002d14
RecursionCount     = 0x1
LockSemaphore      = 0xFFFFFFFF
SpinCount          = 0x0000000004000000


0:000> ~
.  0  Id: 29a8.416c Suspend: 0 Teb: 00000000`0092f000 Unfrozen
   1  Id: 29a8.1258 Suspend: 0 Teb: 00000000`00937000 Unfrozen
   2  Id: 29a8.3b8c Suspend: 0 Teb: 00000000`00939000 Unfrozen
   3  Id: 29a8.3598 Suspend: 0 Teb: 00000000`0093b000 Unfrozen
   4  Id: 29a8.41e0 Suspend: 0 Teb: 00000000`0093d000 Unfrozen
   5  Id: 29a8.4270 Suspend: 0 Teb: 00000000`0093f000 Unfrozen
   6  Id: 29a8.3e38 Suspend: 0 Teb: 00000000`00941000 Unfrozen
   7  Id: 29a8.2f4c Suspend: 0 Teb: 00000000`00943000 Unfrozen
   8  Id: 29a8.3aa4 Suspend: 0 Teb: 00000000`00945000 Unfrozen
   9  Id: 29a8.1874 Suspend: 0 Teb: 00000000`00947000 Unfrozen
  10  Id: 29a8.4354 Suspend: 0 Teb: 00000000`00949000 Unfrozen
  11  Id: 29a8.9ec Suspend: 0 Teb: 00000000`0094b000 Unfrozen
  12  Id: 29a8.3f8c Suspend: 0 Teb: 00000000`0094d000 Unfrozen
  13  Id: 29a8.2874 Suspend: 0 Teb: 00000000`0094f000 Unfrozen
  14  Id: 29a8.1184 Suspend: 0 Teb: 00000000`00951000 Unfrozen
  15  Id: 29a8.2e84 Suspend: 0 Teb: 00000000`00953000 Unfrozen
  16  Id: 29a8.dcc Suspend: 0 Teb: 00000000`00955000 Unfrozen
  17  Id: 29a8.3f48 Suspend: 0 Teb: 00000000`00957000 Unfrozen
  18  Id: 29a8.1df0 Suspend: 0 Teb: 00000000`00959000 Unfrozen
  19  Id: 29a8.42e4 Suspend: 0 Teb: 00000000`0095b000 Unfrozen
  20  Id: 29a8.2c60 Suspend: 0 Teb: 00000000`0095d000 Unfrozen
  21  Id: 29a8.3724 Suspend: 0 Teb: 00000000`0095f000 Unfrozen
  22  Id: 29a8.1fd0 Suspend: 0 Teb: 00000000`00961000 Unfrozen
  23  Id: 29a8.4178 Suspend: 0 Teb: 00000000`00963000 Unfrozen
  24  Id: 29a8.37f8 Suspend: 0 Teb: 00000000`00965000 Unfrozen
  25  Id: 29a8.2984 Suspend: 0 Teb: 00000000`00967000 Unfrozen
  26  Id: 29a8.3d48 Suspend: 0 Teb: 00000000`00969000 Unfrozen
  27  Id: 29a8.432c Suspend: 0 Teb: 00000000`00973000 Unfrozen
  28  Id: 29a8.a2c Suspend: 0 Teb: 00000000`00975000 Unfrozen
  29  Id: 29a8.3aac Suspend: 0 Teb: 00000000`00977000 Unfrozen
  30  Id: 29a8.3b24 Suspend: 0 Teb: 00000000`00979000 Unfrozen
  31  Id: 29a8.3088 Suspend: 0 Teb: 00000000`0097b000 Unfrozen
  32  Id: 29a8.2e30 Suspend: 0 Teb: 00000000`0097f000 Unfrozen
  33  Id: 29a8.4208 Suspend: 0 Teb: 00000000`00989000 Unfrozen
  34  Id: 29a8.1e80 Suspend: 0 Teb: 00000000`0098b000 Unfrozen
  35  Id: 29a8.4014 Suspend: 0 Teb: 00000000`0098f000 Unfrozen
  36  Id: 29a8.2970 Suspend: 0 Teb: 00000000`00991000 Unfrozen
  37  Id: 29a8.42d4 Suspend: 0 Teb: 00000000`00993000 Unfrozen
  38  Id: 29a8.3414 Suspend: 0 Teb: 00000000`00995000 Unfrozen
  39  Id: 29a8.b50 Suspend: 0 Teb: 00000000`009a5000 Unfrozen
  40  Id: 29a8.3c1c Suspend: 0 Teb: 00000000`009a7000 Unfrozen
  41  Id: 29a8.b8c Suspend: 0 Teb: 00000000`009a9000 Unfrozen
  42  Id: 29a8.b24 Suspend: 0 Teb: 00000000`009ab000 Unfrozen
  43  Id: 29a8.3b54 Suspend: 0 Teb: 00000000`009ad000 Unfrozen
  44  Id: 29a8.4300 Suspend: 0 Teb: 00000000`009af000 Unfrozen
  45  Id: 29a8.6c0 Suspend: 0 Teb: 00000000`009b3000 Unfrozen
  46  Id: 29a8.4374 Suspend: 0 Teb: 00000000`009b5000 Unfrozen
  47  Id: 29a8.41f8 Suspend: 0 Teb: 00000000`009cd000 Unfrozen
  48  Id: 29a8.3528 Suspend: 0 Teb: 00000000`009db000 Unfrozen
  49  Id: 29a8.3d88 Suspend: 0 Teb: 00000000`009f3000 Unfrozen
  50  Id: 29a8.38a4 Suspend: 0 Teb: 00000000`009a1000 Unfrozen
  51  Id: 29a8.4274 Suspend: 0 Teb: 00000000`0084a000 Unfrozen
  52  Id: 29a8.4058 Suspend: 0 Teb: 00000000`00870000 Unfrozen
  53  Id: 29a8.1c80 Suspend: 0 Teb: 00000000`00820000 Unfrozen
  54  Id: 29a8.14f0 Suspend: 0 Teb: 00000000`00822000 Unfrozen
  55  Id: 29a8.4324 Suspend: 0 Teb: 00000000`00824000 Unfrozen
  56  Id: 29a8.2810 Suspend: 0 Teb: 00000000`00826000 Unfrozen
  57  Id: 29a8.2d14 Suspend: 0 Teb: 00000000`00828000 Unfrozen
  58  Id: 29a8.2d18 Suspend: 0 Teb: 00000000`0082a000 Unfrozen
  59  Id: 29a8.34c4 Suspend: 0 Teb: 00000000`0089a000 Unfrozen
  60  Id: 29a8.38b4 Suspend: 0 Teb: 00000000`0089e000 Unfrozen
  61  Id: 29a8.43c4 Suspend: 0 Teb: 00000000`00983000 Unfrozen
  62  Id: 29a8.415c Suspend: 0 Teb: 00000000`008d8000 Unfrozen
  63  Id: 29a8.2308 Suspend: 0 Teb: 00000000`00812000 Unfrozen
  64  Id: 29a8.3fd8 Suspend: 0 Teb: 00000000`00814000 Unfrozen
  65  Id: 29a8.413c Suspend: 0 Teb: 00000000`00816000 Unfrozen
  66  Id: 29a8.3ee4 Suspend: 0 Teb: 00000000`00818000 Unfrozen
  67  Id: 29a8.2ddc Suspend: 0 Teb: 00000000`00872000 Unfrozen
  68  Id: 29a8.3c0c Suspend: 0 Teb: 00000000`009f7000 Unfrozen
  69  Id: 29a8.22c4 Suspend: 0 Teb: 00000000`0092a000 Unfrozen
  70  Id: 29a8.30f4 Suspend: 0 Teb: 00000000`009d1000 Unfrozen
  71  Id: 29a8.3660 Suspend: 0 Teb: 00000000`009d3000 Unfrozen
  72  Id: 29a8.2cd0 Suspend: 0 Teb: 00000000`009d5000 Unfrozen
  73  Id: 29a8.41a8 Suspend: 0 Teb: 00000000`009d7000 Unfrozen
  74  Id: 29a8.1b6c Suspend: 0 Teb: 00000000`009d9000 Unfrozen
  75  Id: 29a8.3a84 Suspend: 0 Teb: 00000000`009dd000 Unfrozen
  76  Id: 29a8.2714 Suspend: 0 Teb: 00000000`009df000 Unfrozen
  77  Id: 29a8.3988 Suspend: 0 Teb: 00000000`009e1000 Unfrozen
  78  Id: 29a8.43b8 Suspend: 0 Teb: 00000000`009e3000 Unfrozen
  79  Id: 29a8.2834 Suspend: 0 Teb: 00000000`009e5000 Unfrozen
  80  Id: 29a8.3bfc Suspend: 0 Teb: 00000000`009e7000 Unfrozen

0:000> ~57 kv
 # Child-SP          RetAddr           : Args to Child                                                           : Call Site
00 00000000`6aaff7c8 00007ff8`96b245c3 : 00000000`00000000 00000000`527001ea 00000000`00000030 00000000`00000030 : ntdll!NtWaitForSingleObject+0x14
01 00000000`6aaff7d0 00000000`528b3a8d : 00000000`3d7c9200 00000000`02ac4440 00000000`00000000 00000000`00000cd8 : KERNELBASE!WaitForSingleObjectEx+0x93
02 00000000`6aaff870 00000000`5282cd5b : 00000000`3d7c9200 00000000`02ac4440 00000000`3d87d800 00000000`00000000 : jvm!JVM_RaiseSignal+0x523d
03 00000000`6aaff8a0 00000000`5282d3b7 : 00000000`3d87d800 00000000`02ac4440 00000000`00000000 00007ff8`9a219860 : jvm!JVM_Sleep+0x7c88b
04 00000000`6aaff8d0 00000000`5276f785 : 00000000`00000000 00000000`3d87d800 00000000`00000001 00000000`6aaffa70 : jvm!JVM_Sleep+0x7cee7
05 00000000`6aaff900 00007ff8`3ed36377 : 00000000`5a938b28 00000000`00000001 00000000`00000001 60f632d9`00000003 : jvm!JNI_CreateJavaVM+0x205
06 00000000`6aaff9a0 00007ff8`3ed4937b : 00000000`5a938b28 00000000`00000001 7ff00000`00000000 00000000`6aaffa70 : jfxwebkit!WTF::isMainThread+0x57
07 00000000`6aaff9f0 00007ff8`3eee58fd : 00000000`00000001 00007ff8`9a1d267d 00000000`001d0000 00007ff8`711530de : jfxwebkit!WTF::Thread::create+0x29b
08 00000000`6aaffb30 00007ff8`3ee2d077 : 00000000`00000020 00000000`56efceb0 00000000`56efcea0 00000000`56efce70 : jfxwebkit!WTF::platformUserPreferredLanguages+0x15a95d
09 00000000`6aaffb60 00007ff8`9a208f07 : 00000000`7ffe0385 00000000`00000000 00000000`00000003 00000000`7ffe0384 : jfxwebkit!WTF::platformUserPreferredLanguages+0xa20d7
0a 00000000`6aaffb90 00007ff8`9a20903b : 00007ff8`3eee8a00 00007ff8`3d660000 00007ff8`00000003 00000000`00828000 : ntdll!LdrpCallInitRoutine+0x6f
0b 00000000`6aaffc00 00007ff8`9a2065b1 : 00000000`00828000 00000000`00828000 00007ff8`3eee8a00 00007ff8`3ee2d014 : ntdll!LdrpCallTlsInitializers+0x87
0c 00000000`6aaffc80 00007ff8`9a22a2be : 00000000`3d0b0d00 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!LdrShutdownThread+0x141
0d 00000000`6aaffd80 00007ff8`96b4772a : 00007ff8`3d660000 00000000`00000000 00000000`3d0b0d50 00000000`00000000 : ntdll!RtlExitUserThread+0x3e
0e 00000000`6aaffdc0 00007ff8`96ff04c4 : 00000000`5c6857b0 00000000`00000000 00000000`00000000 00000000`00000000 : KERNELBASE!FreeLibraryAndExitThread+0x4a
0f 00000000`6aaffdf0 00007ff8`96ff03c1 : 00000000`5c6857b0 00000000`5c6857b0 00000000`00000000 00000000`00000000 : ucrtbase!common_end_thread+0xa4
10 00000000`6aaffe20 00007ff8`99ad81f4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ucrtbase!thread_start<unsigned int (__cdecl*)(void * __ptr64)>+0x41
11 00000000`6aaffe50 00007ff8`9a22a251 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : kernel32!BaseThreadInitThunk+0x14
12 00000000`6aaffe80 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21

Once the crash loaded, we looked for locks. It seems there was one in thread 2d14. We dumped the stack trace for it. It seems blocked somewhere in the jfxwebkit!WTF layers.

Without the Webview our applications with JavaFX run for ages without any issue.

@jmborer jmborer changed the title Java application using WebView eventually freeze Java application using JavaFX WebView eventually freeze Jan 20, 2021
@jmborer jmborer changed the title Java application using JavaFX WebView eventually freeze Java applications using JavaFX WebView eventually freeze Jan 20, 2021
@marcellanz
Copy link

@jmborer have you been able to solve or mitigate this issue?
A customer of mine has a similar issue, actually, they use a webview and when I analyze the process dump file, I get to the very same thread and stacks as yours. Happens in Oracle JRE 1.8 241 for us; and might in others too. I should get at least two more windows process dump files next week. Beside that, would you share more information about the environment where that happens?�

@jmborer
Copy link
Author

jmborer commented Mar 11, 2021 via email

@scientificware
Copy link
Contributor

It seems to me a similar problem was posted in the new JavaFX repository https://github.com/openjdk/jfx

@marcellanz
Copy link

@marcellanz
Copy link

Hello, Unfortunately, no. We had to use another solution. Even inactive pages with blank content lead to freezes. It was just a matter of time. The other dumps were not really interesting. We use Win10. We had the issues with all Java 8 JVMs from Oracle and zulu (current to n-3). We have switched to JxBrowser which is a better replacement even though you will need a license. Hope it helps Jm

Thanks JM

@scientificware
Copy link
Contributor

@marcellanz Sorry I was in mind this one 8260257.

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

No branches or pull requests

3 participants