Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build jsaddle-webkit2gtk #85

Open
vaibhavsagar opened this issue Feb 7, 2019 · 11 comments
Open

Can't build jsaddle-webkit2gtk #85

vaibhavsagar opened this issue Feb 7, 2019 · 11 comments

Comments

@vaibhavsagar
Copy link

It looks like GI.JavaScriptCore and GI.WebKit2 have changed in incompatible ways:

Building library for jsaddle-webkit2gtk-0.9.6.0..
[1 of 1] Compiling Language.Javascript.JSaddle.WebKitGTK ( src/Language/Javascript/JSaddle/WebKitGTK.hs, dist/build/Language/Javascript/JSaddle/WebKitGTK.o )

src/Language/Javascript/JSaddle/WebKitGTK.hs:68:38-54: error:
    Module ‘GI.JavaScriptCore’ does not export ‘GlobalContext(..)’
   |
68 | import GI.JavaScriptCore (Value(..), GlobalContext(..))
   |                                      ^^^^^^^^^^^^^^^^^

src/Language/Javascript/JSaddle/WebKitGTK.hs:77:9-32: error:
    Module ‘GI.WebKit2’ does not export ‘javascriptResultGetValue’
   |
77 |         javascriptResultGetValue, javascriptResultGetGlobalContext,
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

src/Language/Javascript/JSaddle/WebKitGTK.hs:77:35-66: error:
    Module
    ‘GI.WebKit2’
    does not export
    ‘javascriptResultGetGlobalContext’
   |
77 |         javascriptResultGetValue, javascriptResultGetGlobalContext,
   |  

To reproduce, use this default.nix:

let
  nixpkgs-src = builtins.fetchTarball {
    url = "https://github.com/NixOS/nixpkgs/archive/6a0d2ff7c1d024914a3570b85f1c88df8930b471.tar.gz";
    sha256 = "06q10786lj7yig6spzsz1zflcjqxjj11d5qsr305jln34wndlj27";
  };
  jsaddle-src = builtins.fetchTarball {
    url = "https://github.com/ghcjs/jsaddle/archive/98a00b334b0ce62bf6bd3a4af682b25a8ea28193.tar.gz";
    sha256 = "057a4imgyq4aabsqhlv9zd3z855cwii2qq8i5hmfnfmc9wcx403l";
  };
  pkgs = import nixpkgs-src {};
  haskellPackages = pkgs.haskellPackages.override {
    overrides = self: super: {
      jsaddle = self.callCabal2nix "jsaddle" (jsaddle-src + "/jsaddle") {};
      jsaddle-webkit2gtk = self.callCabal2nix "jsaddle-webkit2gtk" (jsaddle-src + "/jsaddle-webkit2gtk") {};
      haskell-gi-overloading = self.callHackage "haskell-gi-overloading" "0.0" {};
    };
  };
in haskellPackages.jsaddle-webkit2gtk
@guibou
Copy link

guibou commented Feb 12, 2019

Current nixpkgs uses webkit-gtk-2.22. I wonder if jsaddle-webkit2gtk is not based on previous version (and API?)

@develop7
Copy link

develop7 commented Mar 1, 2019

This affects me too. Seems to be caused by the lack of said GlobalContext in gi-javascriptcore-4.0.16 (it is present in 4.0.15 though!)

@chessai
Copy link
Contributor

chessai commented Mar 23, 2019

I am also experiencing this.

@amanbhurji
Copy link

Me too. Using 4.0.15 only changes the error to -

GI/JavaScriptCore/Objects/Exception.hs:120:1: error:
    Could not find module ‘GI.GObject.Objects.Object’

@ryantrinkle
Copy link

This builds (and so do lots of transitive dependent packages), but I haven't tested it: https://github.com/ryantrinkle/jsaddle/tree/no-global-context

@develop7
Copy link

develop7 commented Apr 29, 2019

Thank your for looking into it, @ryantrinkle. I've built a "hello world" reflex app (built with Stack though, not Nix) using jsaddle from above branch; it shows empty window then segfaults in libjavascriptcoregtk:

$ coredumpctl gdb
           PID: 27757 (reflex-stack-ex)
           UID: 1000 (develop7)
           GID: 100 (users)
        Signal: 11 (SEGV)
     Timestamp: Mon 2019-04-29 22:52:36 +03 (19min ago)
  Command Line: /home/develop7/projects/reflex-stack/.stack-work/install/x86_64-linux-tinfo6/lts-12.26/8.4.4/bin/reflex-stack-exe
    Executable: /home/develop7/projects/reflex-stack/.stack-work/install/x86_64-linux-tinfo6/lts-12.26/8.4.4/bin/reflex-stack-exe
 Control Group: /user.slice/user-1000.slice/session-2.scope
          Unit: session-2.scope
         Slice: user-1000.slice
       Session: 2
     Owner UID: 1000 (develop7)
       Boot ID: 34ad9b77fbf44d83a582ae08838287e4
    Machine ID: f7d12f47fb5c49979f8d99a60666bab2
      Hostname: t-rex
       Storage: /var/lib/systemd/coredump/core.reflex-stack-ex.1000.34ad9b77fbf44d83a582ae08838287e4.27757.1556567556000000.lz4
       Message: Process 27757 (reflex-stack-ex) of user 1000 dumped core.
                
                Stack trace of thread 27757:
                #0  0x00007fae3b35b763 _ZN3JSC12JSLockHolderC2ERNS_2VME (libjavascriptcoregtk-4.0.so.18)
                #1  0x00007fae3a9e7bad JSValueToStringCopy (libjavascriptcoregtk-4.0.so.18)
                #2  0x00000000004a9de6 n/a (/home/develop7/projects/reflex-stack/.stack-work/install/x86_64-linux-tinfo6/lts-12.26/8.4.4/bin/reflex-stack-exe)
…skip…
Program terminated with signal SIGSEGV, Segmentation fault.
#0  std::__atomic_base<unsigned int>::operator++ () at /usr/include/c++/8/bits/atomic_base.h:296
296	      { return __atomic_add_fetch(&_M_i, 1, memory_order_seq_cst); }
[Current thread is 1 (Thread 0x7fae3a3bdb00 (LWP 27757))]
(gdb) bt
#0  0x00007fae3b35b763 in std::__atomic_base<unsigned int>::operator++() () at /usr/include/c++/8/bits/atomic_base.h:296
#1  0x00007fae3b35b763 in WTF::ThreadSafeRefCountedBase::ref() const () at DerivedSources/ForwardingHeaders/wtf/ThreadSafeRefCounted.h:43
#2  0x00007fae3b35b763 in WTF::refIfNotNull<JSC::VM>(JSC::VM*) () at DerivedSources/ForwardingHeaders/wtf/RefPtr.h:38
#3  0x00007fae3b35b763 in WTF::RefPtr<JSC::VM, WTF::DumbPtrTraits<JSC::VM> >::RefPtr(JSC::VM*) () at DerivedSources/ForwardingHeaders/wtf/RefPtr.h:57
#4  0x00007fae3b35b763 in JSC::JSLockHolder::JSLockHolder(JSC::VM&) () at ../Source/JavaScriptCore/runtime/JSLock.cpp:64
#5  0x00007fae3a9e7bad in JSValueToStringCopy() () at ../Source/JavaScriptCore/API/JSValueRef.cpp:432
#6  0x00000000004a9de6 in  ()
#7  0x0000000004b17d68 in  ()
#8  0x0000000001e93ed8 in  ()
#9  0x0000000000000000 in  ()

Hope that helps making further progress.

@ryantrinkle
Copy link

@develop7 Ah, looks like I guessed wrong about GlobalContext and Context being sufficiently interchangeable. Maybe @hamishmack has an idea?

@hamishmack
Copy link
Member

I think the first step is to create a Haskell library to wrap the new jsc-glib library that is now in webkitgtk. This new haskell library would take the place of the webkit2-javascriptcore that jsaddle-webkit2gtk currently uses.

Unfortunately I don't think jsc-glib has gobject introspection (though I would love to be proved wrong on that). Hopefully once we have that we can replace the code that currently calls C functions like JSValueToStringCopy with code that calls the new C functions like jsc-value-to-string-as-bytes.

I think we should avoid any dependency on gtk2hs-buildtools and instead use a more standard tool like hsc2hs. The gi-cairo-render package might be a useful place to look for ideas and @cohomology might have some good tips on how to create a haskell bindings for a C library with good haskell-gi interop.

Another option is to add FFI imports for just the jsc-glib functions we need in line in the jsaddle-webkit2gtk code (that might be less work, but it would suck a little).

@ali-abrar
Copy link
Contributor

I think #96 fixes this by avoiding global context entirely. I was able to build and run reflex-todomvc with that patch.

ali-abrar added a commit to reflex-frp/reflex-platform that referenced this issue Jul 9, 2019
@vaibhavsagar
Copy link
Author

This is so exciting! Maybe we can finally get servant-client-jsaddle over the finish line 😄.

@develop7
Copy link

I think #96 fixes this by avoiding global context entirely. I was able to build and run reflex-todomvc with that patch.

yup, that does it — just got reflex "hello world" running in webkitgtk. Thanks, man!

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

No branches or pull requests

8 participants