reflex-platform
reflex-platform copied to clipboard
jsaddle-webkit2gtk sometimes produces blank window
On some computers jsaddle-webkit2gtk based applications fail to render anything and just show blank screen (see hello world example below). It clearly depends on PC configuration since it's 100% reproducible on some computers and and doesn't happen on others. We don't know what makes the difference
More precisely, at first application displays empty white window and able to redraw it. After single click it stop redrawing it.
# OS
$ nixos-version --json | jq
{
"nixosVersion": "21.05.1790.382039c05a1",
"nixpkgsRevision": "382039c05a16827a7f0731183e862366b66b422f"
}
# reflex-patform
$ git show HEAD
commit 904eea80904f93bc72535832d155de315634f187 (HEAD -> develop, origin/develop, origin/HEAD)
Reproducer
{-# LANGUAGE OverloadedStrings #-}
import qualified Language.Javascript.JSaddle.WebKitGTK as WB (run)
import Language.Javascript.JSaddle.Types
import Reflex.Dom
main :: IO ()
main = WB.run hello
hello :: JSM ()
hello = do
mainWidget' $ el "div" $ text "Welcome to Reflex"
I reproduced this issue after installing Fira Code font on NixOS using nix-env -iA nixos.fira-code
. Before that, everything worked fine.
Looks like I ran into this issue too. I'm getting a blank white window in my own Nix shell, but the same code renders "Hello, World!" correctly with reflex-platform.
On the version that doesn't work, I get the following message on STDERR:
Could not determine the accessibility bus address
I suspect that this is related to my weird XMonad/dbus/etc setup and not the cause of the problem, but I am not sure.
I tried running my own version with nix develop -i
(equivalent to nix-shell --pure
) to control for the rest of my environment, but couldn't get that to work at all. Based on #737 I thought it could be something to do with fonts and fontconfig, so I tried compiling and running the same code in an environment with no extra fonts installed, but that did not change anything.
I have no ideas for how to debug this further or even how to get more information from the system about what's going wrong. Happy to help if anybody else is looking at this but struggling to reproduce the issue!
Here's the repo for the failing code, which should be reproducible with the flake.nix file.
Update: figured out how to fix the accessibility warning, but still having the blank window problem.
Okay, playing around a bit more, I've found two relevant things:
- My problem is not specific to reflex-dom or jsaddle—using the gi-gtk bindings directly had the same issue
- The webview has the content, it just isn't rendering. The inspector window works, shows the DOM elements my code created and my cursor changes a I mouse over links/etc. I can even take screenshots from the inspector that render the contents correctly, it's just a blank screen in the window itself.
I don't know if this is the same problem as what originally prompted this issue, and it looks like it's caused somewhere further up in the stack. I'll poke around a bit more, but I still don't have a real idea for what could be causing this behavior :/
Found the culprit: there's a recurring problem with Webkit2 GTK on Linux with NVidia graphics cards. I'm using the proprietary NVidia drivers, but not sure whether that matters.
I was able to solve the problem by turning hardware acceleration off:
export WEBKIT_DISABLE_COMPOSITING_MODE=1
Turning off the hardware acceleration with the low-level GTK bindings also worked:
webview <- new Gtk.WebView []
settings <- Gtk.webViewGetSettings webview
set settings
[ #hardwareAccelerationPolicy := Gtk.HardwareAccelerationPolicyNever ]
If anybody runs into problems with blank windows on jsaddle-webkit2gtk, this is probably worth trying.