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

Alert boxes are broken on Linux. #222

Closed
zilti opened this issue Sep 26, 2018 · 31 comments
Closed

Alert boxes are broken on Linux. #222

zilti opened this issue Sep 26, 2018 · 31 comments
Labels
bug Something isn't working

Comments

@zilti
Copy link

zilti commented Sep 26, 2018

This happens with both OpenJDK 10 & 11 with OpenJFX from Maven on Linux. More often than not, it turns out like this:

The alert window

I tried setMinWidth and setMinHeight, but these seem to make no difference at all. My code:

Alert alert = new Alert(AlertType/INFORMATION);
alert.setTitle("Testtitle");
alert.setContentText("Some example content text for an alert box.");
alert.getDialogPane.setMinHeight(Region.USE_PREF_SIZE);
alert.getDialogPane.setMinWidth(Region.USE_PREF_SIZE);
alert.showAndWait();

This is being run on the JavaFX application thread. The application is running on OpenSUSE Tumbleweed with KDE Plasma.

@moacirrf
Copy link

moacirrf commented Sep 26, 2018 via email

@zilti
Copy link
Author

zilti commented Sep 27, 2018

Okay. Where is myStage from? Is there a way to extract this from the Alert instance?

@DJViking
Copy link

DJViking commented Sep 27, 2018

I can confirm this problem. It also happens on dialogs that extends Dialog. I reported this issue a while back. https://bugs.openjdk.java.net/browse/JDK-8179073
I also mentioned this bug on the openjfx-dev mailinglist
http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-April/021759.html

@johanvos
Copy link
Collaborator

I try to reproduce the problem, but it works for me on Ubuntu 18.04
Does the follow app shows a wrong dialog size?


package alerttest;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class AlertTest extends Application {

    public void start(Stage stage) throws Exception {
        BorderPane bp = new BorderPane();
        Button al = new Button("Show Alert");
        al.setOnAction(e -> showAlert());
        bp.setCenter(al);
        stage.setScene(new Scene(bp));
        stage.show();
    }

    private void showAlert() {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Testtitle");
        alert.setContentText("Some example content text for an alert box.");
        alert.showAndWait();
    }

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

}

@moacirrf
Copy link

Okay. Where is myStage from? Is there a way to extract this from the Alert instance?

Platform.runLater(() -> {
alert.getDialogPane().getScene().getWindow().sizeToScene();
});

@moacirrf
Copy link

moacirrf commented Sep 27, 2018

I try to reproduce the problem, but it works for me on Ubuntu 18.04
Does the follow app shows a wrong dialog size?


package alerttest;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class AlertTest extends Application {

    public void start(Stage stage) throws Exception {
        BorderPane bp = new BorderPane();
        Button al = new Button("Show Alert");
        al.setOnAction(e -> showAlert());
        bp.setCenter(al);
        stage.setScene(new Scene(bp));
        stage.show();
    }

    private void showAlert() {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Testtitle");
        alert.setContentText("Some example content text for an alert box.");
        alert.showAndWait();
    }

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

}

Im using Manjaro Kde/Plasma, this is kind a random problem, i never know when will happen.So to prevent i ever call sizeToScene on separated thread from the stage that i want to show.
Obs: English is not my first language.

@zilti
Copy link
Author

zilti commented Sep 27, 2018

alert.getDialogPane().getScene().getWindow().sizeToScene();

This seems to fix it, thank you! I think it is a bug that OpenJFX doesn't do this automatically in showAndWait before showing the dialog?

@kevinrushforth
Copy link
Collaborator

Yes, the above is a workaround for what looks like a platform-specific bug in JavaFX. FX already does size the scene automatically before showing it. For some reason it seems this isn't working on Linux in all cases (maybe it depends on the Window manager)

@DJViking
Copy link

DJViking commented Sep 27, 2018

Running OpenSUSE Leap 15.0 and KDE Plasma 5, running on NVIDIA proprietary drivers.

It is not consistent. Some times I get the dialog in full size.
screenshot_20180927_154601
screenshot_20180927_154623

This also happens on SceneBuilder when trying to exit. Press Esc and retry until it shows.

@eugener eugener added the bug Something isn't working label Sep 27, 2018
@zilti
Copy link
Author

zilti commented Sep 27, 2018

Correction: no, it doesn't fix it, unfortunately. I still get the same problem. I just had a bit of luck two times in a row...

@moacirrf
Copy link

moacirrf commented Sep 30, 2018

I had a strange message from kernel, while running a simple test:
29/09/2018 22:33 R13 0000000040051000 R14: 0000000000000263 R15: 0000000000001318
29/09/2018 22:35 BUG Bad page map in process QuantumRenderer pte:800000003affe025 pmd:1f6027067
29/09/2018 22:35 page ffff694c0ebff80 count:2 mapcount:-511 mapping: (null) index:0x0
29/09/2018 22:35 flags 0x1fffe0000000000()
29/09/2018 22:35 raw 01fffe0000000000 0000000000000000 0000000000000000 00000002fffffe00
29/09/2018 22:35 raw dead000000000100 dead000000000200 0000000000000000 ffff9302336d8000
29/09/2018 22:35 page dumped because bad pte
29/09/2018 22:35 page->mem_cgroup fff9302336d8000
29/09/2018 22:35 addr 0007fd6cded2000 vm_flags:040400d9 anon_vma: (null) mapping:ffff930220f4f980 index:40052
29/09/2018 22:35 file ard0 fault:ip_vm_kmap_fault [fglrx] mmap:ip_firegl_mmap [fglrx] readpage: (null)
29/09/2018 22:35 CPU 1 PID: 3896 Comm: QuantumRenderer Tainted: G B C O 4.14.71-1-MANJARO #1
29/09/2018 22:35 Hardware name To Be Filled By O.E.M. To Be Filled By O.E.M./FM2A58M-VG3+, BIOS P2.80 01/11/2016
29/09/2018 22:35 Call Trace
29/09/2018 22:35 dump_stack+0x5c/0x85
29/09/2018 22:35 print_bad_pte.cold.104+0x9a/0xc4
29/09/2018 22:35 ? lock_page_memcg+0x11/0x80
29/09/2018 22:35 unmap_page_range+0x9c8/0xbf0
29/09/2018 22:35 unmap_vmas+0x78/0xa0
29/09/2018 22:35 unmap_region+0xae/0x110
29/09/2018 22:35 ? __vma_rb_erase+0x127/0x250
29/09/2018 22:35 do_munmap+0x27f/0x430
29/09/2018 22:35 vm_munmap+0x5f/0xa0
29/09/2018 22:35 SyS_munmap+0x1d/0x30
29/09/2018 22:35 do_syscall_64+0x6e/0x100
29/09/2018 22:35 entry_SYSCALL_64_after_hwframe+0x3d/0xa2
29/09/2018 22:35 RIP 0033:0x7fd6cf4b668b
29/09/2018 22:35 RSP 002b:00007fd68a7dc968 EFLAGS: 00000202 ORIG_RAX: 000000000000000b
29/09/2018 22:35 RAX ffffffffffffffda RBX: 000000000000000a RCX: 00007fd6cf4b668b
29/09/2018 22:35 RDX 00007fd68a7dc97c RSI: 0000000000001000 RDI: 00007fd6cded2000
29/09/2018 22:35 RBP 0000000000001000 R08: 0000000000000003 R09: 0000000000000002
29/09/2018 22:35 R10 0000000000000000 R11: 0000000000000202 R12: 00007fd6cded2000
29/09/2018 22:35 R13 0000000040052000 R14: 00000000000003c2 R15: 0000000000001e10
29/09/2018 22:35 BUG Bad page map in process QuantumRenderer pte:8000000004f5f025 pmd:1276d9067
29/09/2018 22:35 page ffff694c013d7c0 count:2 mapcount:-511 mapping: (null) index:0x0
29/09/2018 22:35 flags 0x1fffe0000000000()
29/09/2018 22:35 raw 01fffe0000000000 0000000000000000 0000000000000000 00000002fffffe00
29/09/2018 22:35 raw dead000000000100 dead000000000200 0000000000000000 ffff9302336d8000
29/09/2018 22:35 page dumped because bad pte
29/09/2018 22:35 page->mem_cgroup fff9302336d8000
29/09/2018 22:35 addr 0007fd6a4003000 vm_flags:040400d9 anon_vma: (null) mapping:ffff930220f4f980 index:40053
29/09/2018 22:35 file ard0 fault:ip_vm_kmap_fault [fglrx] mmap:ip_firegl_mmap [fglrx] readpage: (null)
29/09/2018 22:35 CPU 1 PID: 3896 Comm: QuantumRenderer Tainted: G B C O 4.14.71-1-MANJARO #1
29/09/2018 22:35 Hardware name To Be Filled By O.E.M. To Be Filled By O.E.M./FM2A58M-VG3+, BIOS P2.80 01/11/2016
29/09/2018 22:35 Call Trace
29/09/2018 22:35 dump_stack+0x5c/0x85
29/09/2018 22:35 print_bad_pte.cold.104+0x9a/0xc4
29/09/2018 22:35 ? lock_page_memcg+0x11/0x80
29/09/2018 22:35 unmap_page_range+0x9c8/0xbf0
29/09/2018 22:35 unmap_vmas+0x78/0xa0
29/09/2018 22:35 unmap_region+0xae/0x110
29/09/2018 22:35 ? __vma_rb_erase+0x127/0x250
29/09/2018 22:35 do_munmap+0x27f/0x430
29/09/2018 22:35 vm_munmap+0x5f/0xa0
29/09/2018 22:35 SyS_munmap+0x1d/0x30
29/09/2018 22:35 do_syscall_64+0x6e/0x100
29/09/2018 22:35 entry_SYSCALL_64_after_hwframe+0x3d/0xa2
29/09/2018 22:35 RIP 0033:0x7fd6cf4b668b
29/09/2018 22:35 RSP 002b:00007fd68a7dcc38 EFLAGS: 00000246 ORIG_RAX: 000000000000000b
29/09/2018 22:35 RAX ffffffffffffffda RBX: 000000000000000a RCX: 00007fd6cf4b668b
29/09/2018 22:35 RDX 00007fd68a7dcc4c RSI: 0000000000001000 RDI: 00007fd6a4003000
29/09/2018 22:35 RBP 0000000000001000 R08: 0000000000000003 R09: 0000000000000002
29/09/2018 22:35 R10 0000000000000000 R11: 0000000000000246 R12: 00007fd6a4003000
29/09/2018 22:35 R13 0000000040053000 R14: 00000000000003c3 R15: 0000000000001e18

@moacirrf
Copy link

moacirrf commented Oct 4, 2018

I had a strange message from kernel, while running a simple test:
29/09/2018 22:33 R13 0000000040051000 R14: 0000000000000263 R15: 0000000000001318
29/09/2018 22:35 BUG Bad page map in process QuantumRenderer pte:800000003affe025 pmd:1f6027067
29/09/2018 22:35 page ffff694c0ebff80 count:2 mapcount:-511 mapping: (null) index:0x0
29/09/2018 22:35 flags 0x1fffe0000000000()
29/09/2018 22:35 raw 01fffe0000000000 0000000000000000 0000000000000000 00000002fffffe00
29/09/2018 22:35 raw dead000000000100 dead000000000200 0000000000000000 ffff9302336d8000
29/09/2018 22:35 page dumped because bad pte
29/09/2018 22:35 page->mem_cgroup fff9302336d8000
29/09/2018 22:35 addr 0007fd6cded2000 vm_flags:040400d9 anon_vma: (null) mapping:ffff930220f4f980 index:40052
29/09/2018 22:35 file ard0 fault:ip_vm_kmap_fault [fglrx] mmap:ip_firegl_mmap [fglrx] readpage: (null)
29/09/2018 22:35 CPU 1 PID: 3896 Comm: QuantumRenderer Tainted: G B C O 4.14.71-1-MANJARO #1
29/09/2018 22:35 Hardware name To Be Filled By O.E.M. To Be Filled By O.E.M./FM2A58M-VG3+, BIOS P2.80 01/11/2016
29/09/2018 22:35 Call Trace
29/09/2018 22:35 dump_stack+0x5c/0x85
29/09/2018 22:35 print_bad_pte.cold.104+0x9a/0xc4
29/09/2018 22:35 ? lock_page_memcg+0x11/0x80
29/09/2018 22:35 unmap_page_range+0x9c8/0xbf0
29/09/2018 22:35 unmap_vmas+0x78/0xa0
29/09/2018 22:35 unmap_region+0xae/0x110
29/09/2018 22:35 ? __vma_rb_erase+0x127/0x250
29/09/2018 22:35 do_munmap+0x27f/0x430
29/09/2018 22:35 vm_munmap+0x5f/0xa0
29/09/2018 22:35 SyS_munmap+0x1d/0x30
29/09/2018 22:35 do_syscall_64+0x6e/0x100
29/09/2018 22:35 entry_SYSCALL_64_after_hwframe+0x3d/0xa2
29/09/2018 22:35 RIP 0033:0x7fd6cf4b668b
29/09/2018 22:35 RSP 002b:00007fd68a7dc968 EFLAGS: 00000202 ORIG_RAX: 000000000000000b
29/09/2018 22:35 RAX ffffffffffffffda RBX: 000000000000000a RCX: 00007fd6cf4b668b
29/09/2018 22:35 RDX 00007fd68a7dc97c RSI: 0000000000001000 RDI: 00007fd6cded2000
29/09/2018 22:35 RBP 0000000000001000 R08: 0000000000000003 R09: 0000000000000002
29/09/2018 22:35 R10 0000000000000000 R11: 0000000000000202 R12: 00007fd6cded2000
29/09/2018 22:35 R13 0000000040052000 R14: 00000000000003c2 R15: 0000000000001e10
29/09/2018 22:35 BUG Bad page map in process QuantumRenderer pte:8000000004f5f025 pmd:1276d9067
29/09/2018 22:35 page ffff694c013d7c0 count:2 mapcount:-511 mapping: (null) index:0x0
29/09/2018 22:35 flags 0x1fffe0000000000()
29/09/2018 22:35 raw 01fffe0000000000 0000000000000000 0000000000000000 00000002fffffe00
29/09/2018 22:35 raw dead000000000100 dead000000000200 0000000000000000 ffff9302336d8000
29/09/2018 22:35 page dumped because bad pte
29/09/2018 22:35 page->mem_cgroup fff9302336d8000
29/09/2018 22:35 addr 0007fd6a4003000 vm_flags:040400d9 anon_vma: (null) mapping:ffff930220f4f980 index:40053
29/09/2018 22:35 file ard0 fault:ip_vm_kmap_fault [fglrx] mmap:ip_firegl_mmap [fglrx] readpage: (null)
29/09/2018 22:35 CPU 1 PID: 3896 Comm: QuantumRenderer Tainted: G B C O 4.14.71-1-MANJARO #1
29/09/2018 22:35 Hardware name To Be Filled By O.E.M. To Be Filled By O.E.M./FM2A58M-VG3+, BIOS P2.80 01/11/2016
29/09/2018 22:35 Call Trace
29/09/2018 22:35 dump_stack+0x5c/0x85
29/09/2018 22:35 print_bad_pte.cold.104+0x9a/0xc4
29/09/2018 22:35 ? lock_page_memcg+0x11/0x80
29/09/2018 22:35 unmap_page_range+0x9c8/0xbf0
29/09/2018 22:35 unmap_vmas+0x78/0xa0
29/09/2018 22:35 unmap_region+0xae/0x110
29/09/2018 22:35 ? __vma_rb_erase+0x127/0x250
29/09/2018 22:35 do_munmap+0x27f/0x430
29/09/2018 22:35 vm_munmap+0x5f/0xa0
29/09/2018 22:35 SyS_munmap+0x1d/0x30
29/09/2018 22:35 do_syscall_64+0x6e/0x100
29/09/2018 22:35 entry_SYSCALL_64_after_hwframe+0x3d/0xa2
29/09/2018 22:35 RIP 0033:0x7fd6cf4b668b
29/09/2018 22:35 RSP 002b:00007fd68a7dcc38 EFLAGS: 00000246 ORIG_RAX: 000000000000000b
29/09/2018 22:35 RAX ffffffffffffffda RBX: 000000000000000a RCX: 00007fd6cf4b668b
29/09/2018 22:35 RDX 00007fd68a7dcc4c RSI: 0000000000001000 RDI: 00007fd6a4003000
29/09/2018 22:35 RBP 0000000000001000 R08: 0000000000000003 R09: 0000000000000002
29/09/2018 22:35 R10 0000000000000000 R11: 0000000000000246 R12: 00007fd6a4003000
29/09/2018 22:35 R13 0000000040053000 R14: 00000000000003c3 R15: 0000000000001e18

This message is not related with javafx, but with driver of my Radeon, i fixed it, and test with 3 diferent drivers: Vesa, Catalyst and Amdgpu(actual), i still get the same problem with alerts.

@Goblin80
Copy link

I think it's a KDE problem, Alerts work fine if i switched my desktop environment to XFCE.

@zilti
Copy link
Author

zilti commented Jan 23, 2019

It's not a KDE problem when

  1. this problem didn't exist in JavaFX 8
  2. JavaFX is the only toolkit to have this problem on KWin.

@moacirrf
Copy link

moacirrf commented Jan 27, 2019

Hi
I recorded a video of this bug while debugging with Scenic View.
We can see that width and height are correctly configured on DialogPane, but the window don't refresh, but if you change expanded property on ScenicView the window are updated to correct size.
https://www.youtube.com/watch?v=uimqwxxp2ZE
If it help someone...

@moacirrf
Copy link

Hello
I checkout source code and did a little change on file:
modules/javafx.graphics/src/main/native-glass/gtk/glass_window.cpp(line 1251)
commented 'gtk_window_resize' and replace by 'gtk_widget_set_size_request'
https://github.com/moacirrf/openjdk-jfx/commit/52db62080fa36f5e544bf5f2c08894d6fadc9125
Now Alert works well, but only on GTK3.
Any ideas?

@moacirrf
Copy link

CompiledLibs.zip
This are my compiled libs
libglass.so,libglassgtk2.so,libglassgtk3.so

If you are using ArchLinux 64bit, maybe you can test.
Backup your originals and replace by this new ones.
Ensure you are using GTK3.

@Folling
Copy link

Folling commented Jan 29, 2019

Confirming this from KDE + ArchLinux.
Another thing that fixes this, is the following:

this.resizable = true
this.onShown = {
    Platform.runLater {
        this.resizable = false
    }
}

Note that I'm using groovy, you can easily translate this into java and it will have the same effect.

This does keep the pane large consistently, however at times it will stay resizable, which seems like an entirely different bug.

@moacirrf
Copy link

Confirming this from KDE + ArchLinux.
Another thing that fixes this, is the following:

this.resizable = true
this.onShown = {
    Platform.runLater {
        setResizable(false)
    }
}

Note that I'm using groovy, you can easily translate this into java and it will have the same effect.

This does keep the pane large consistently, however at times it will stay resizable, which seems like an entirely different bug.

Yes i can confirm that your workaround fix the problem, but as you say, the alert stay resizable.

@moacirrf
Copy link

moacirrf commented Feb 5, 2019

My changes on modules/javafx.graphics/src/main/native-glass/gtk/glass_window.cpp, fixed the problem on Arch Kde\Gtk, but on Arch Gnome, cause and old bug that was fixed, bug that dont show de maximize button.

I think that a simple solution is test if we are using kde.
What do you think about that?.

@moacirrf
Copy link

@moacirrf
Copy link

What you think about that?

@aditsu
Copy link

aditsu commented May 7, 2019

I'm having this problem too, also using KDE/Plasma 5.
The first workaround (sizeToScene) helps but not every time.
The second workaround (setResizable) seems more reliable.

@aditsu
Copy link

aditsu commented May 7, 2019

One solution is test if running on kde:
moacirrf@5d65fb7#diff-0a0704d569190237d6460d29d3c61bf1

Doesn't that just test if your current desktop starts with a K?

@moacirrf
Copy link

moacirrf commented May 7, 2019

One solution is test if running on kde:
moacirrf@5d65fb7#diff-0a0704d569190237d6460d29d3c61bf1

Doesn't that just test if your current desktop starts with a K?
Its true! you are right, correct is use strcmp.
Thank you.

I think that they fixed this bug here:
#456
But i didn't have time to check out.

@DJViking
Copy link

DJViking commented Jun 12, 2019

Now I have experienced this problem with JavaFX 8. Running Oracle JDK 8u212. Reverting back to JDK 8u181 I don't get this problem.
Previously I only experienced this on Java 11. This regression happened right after JDK 9 build 161.
So something that has been backported into JDK 8 has now caused this "regression" there also.

I was hoping this was solved when we where going to move from Java 8 to Java 11, but now I have no choice to find and use a workaround sizeToScene().

@moacirrf
Copy link

moacirrf commented Jun 14, 2019

I can't replicate this bug on Java FX 13 Early-Access.
On my tests, this bug was fixed.
Thanks!

Manjaro KDE 18.0.4

@DJViking
Copy link

DJViking commented Jun 16, 2019

I can't replicate this bug on Java FX 13 Early-Access.
On my tests, this bug was fixed.
Thanks!

Manjaro KDE 18.0.4

As long as the bugfix will be backported to at least JavaFX 11.

@ClementGre
Copy link

ClementGre commented Oct 22, 2019

On JavaFX 11.0.2, you can solve this problem with this code :

alert.setOnShowing(new EventHandler<DialogEvent>() {
    @Override public void handle(DialogEvent e) {
        new Thread(new Runnable() {
            @Override  public void run() {

                try{
                    Thread.sleep(200); // You can change this value if is not working sometimes
                }catch(InterruptedException ex){ ex.printStackTrace();  }

                Platform.runLater(new Runnable(){
                    @Override public void run(){
                        if(alert.getDialogPane().getScene().getWindow().getWidth() < 100){
                            alert.getDialogPane().getScene().getWindow().setWidth(500);
                            alert.getDialogPane().getScene().getWindow().setHeight(200);
                            // You can edit this two values
                        }
                    }
                });

            }
        }, "AlertResizer").start();
    }
});

@kevinrushforth
Copy link
Collaborator

kevinrushforth commented Oct 22, 2019

The question of whether to backport JDK-8193502 is being discussed on the openjfx-dev mailing list in this thread.

@MaaxGr
Copy link

MaaxGr commented Nov 2, 2019

For Kotlin a wrote an extension function, that uses coroutines to workaround the problem:

fun <T> Dialog<T>.disableResizing() {
    isResizable = true
    onShown = EventHandler {
        GlobalScope.launch {
            delay(1)

            Platform.runLater {
                isResizable = false
            }
        }
    }
}

Works in a similar way for disabling stage resize:

fun Stage.disableResizing() {
    isResizable = true
    onShown = EventHandler {
        GlobalScope.launch {
            delay(1)

            Platform.runLater {
                isResizable = false
            }
        }
    }
}

Just in case someone needs a working solution.
Tested on Java 11/13, KDE and Arch

andreig110 added a commit to andreig110/color-palette-generator that referenced this issue Nov 22, 2019
Now 'About' window is a scene, instead of using 'Alerts'.
'Alert' boxes are broken on Linux:
* javafxports/openjdk-jfx#222
* https://bugs.openjdk.java.net/browse/JDK-8179073
* https://stackoverflow.com/q/28937392
immerfroehlich added a commit to immerfroehlich/audio-juicer that referenced this issue Apr 20, 2020
… within a different Thread e.g. a Service Thread for Services that need a user input during execution.; GUI: Added a workaround for bug #222, see javafxports/openjdk-jfx#222
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests