sciter-sdk / go-sciter

Golang bindings of Sciter: the Embeddable HTML/CSS/script engine for modern UI development
https://sciter.com
2.57k stars 268 forks source link

Not connecting to inspector #178

Closed rakkele closed 5 years ago

rakkele commented 5 years ago

I have the following directory:

Andy@Andy-PC MINGW64 /e/sciter
$ ls -la
total 11801
drwxr-xr-x 1 Andy 197121       0 Oct 17 09:05 ./
drwxr-xr-x 1 Andy 197121       0 Oct 17 08:59 ../
-rw-r--r-- 1 Andy 197121     519 Oct 17 09:16 index.html
-rwxr-xr-x 1 Andy 197121  197112 Oct 15 23:14 inspector.exe*
-rw-r--r-- 1 Andy 197121     692 Oct 17 09:15 main.go
-rwxr-xr-x 1 Andy 197121  612856 Oct 15 23:14 notes.exe*
-rwxr-xr-x 1 Andy 197121  159744 Oct 15 23:14 Project1.exe*
-rwxr-xr-x 1 Andy 197121 7178752 Oct 15 23:14 scapp.exe*
-rwxr-xr-x 1 Andy 197121 7274488 Oct 15 23:14 sciter.dll*
-rwxr-xr-x 1 Andy 197121  652280 Oct 15 23:14 sciter.exe*
-rwxr-xr-x 1 Andy 197121  455680 Oct 15 23:14 sciter-dx.exe*
-rwxr-xr-x 1 Andy 197121  740864 Oct 15 23:14 tiscript-sqlite.dll*
-rwxr-xr-x 1 Andy 197121  172032 Oct 15 23:14 ulayered.exe*
-rwxr-xr-x 1 Andy 197121  710144 Oct 15 23:14 usciter.exe*

All files except index.html and main.go are from the sciter sdk /bin/64 at commit f0a69d5d265f12928f997d186a4a1d749fa20e4e.

main.go:

package main

import (
    "fmt"

    "github.com/sciter-sdk/go-sciter"
    "github.com/sciter-sdk/go-sciter/window"
)

func log(args ...*sciter.Value) *sciter.Value {
    if len(args) == 0 {
        return nil
    }
    stringArgs := make([]interface{}, 0, len(args))
    for _, arg := range args {
        stringArgs = append(stringArgs, arg.String())
    }
    fmt.Println(stringArgs...)
    return sciter.NullValue()
}

func main() {
    w, err := window.New(sciter.DefaultWindowCreateFlag, sciter.DefaultRect)
    if err != nil {
        panic(err)
    }
    w.DefineFunction("log", log)
    err = w.LoadFile("index.html")
    if err != nil {
        panic(err)
    }
    w.Show()
    w.Run()
}

index.html:

<html>
    <head>
        <script type="text/tiscript">
            function self.ready(){
                if(view.connectToInspector){
                    view.log("has view.connectToInspector");
                    view.connectToInspector();
                    view.log("connected to inspector");
                }else{
                    view.log("no view.connectToInspector");
                }
            }
        </script>
    </head>
    <body>
        Hello World!
    </body>
</html>

I start inspector.exe and execute following commands

Andy@Andy-PC MINGW64 /e/sciter
$ go get -u github.com/sciter-sdk/go-sciter

Andy@Andy-PC MINGW64 /e/sciter
$ go run main.go
has view.connectToInspector

The window appears, "Hello World!" is printed in it, everything works as expected, except that the inspector never gets a connection and view.log("connected to inspector"); seems to be never reached.

If I comment out all the view.log(...); lines and execute

Andy@Andy-PC MINGW64 /e/sciter
$ ./scapp index.html

the inspector gets immediately connected. go run main.go still doesn't connect, and commenting out the entire tiscript block from index.html and using CTRL+SHIFT+I has no effect.

My go env:

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Andy\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=E:\dev\go
set GOPROXY=
set GORACE=
set GOROOT=E:\Programs\Go1.11
set GOTMPDIR=
set GOTOOLDIR=E:\Programs\Go1.11\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\Andy\AppData\Local\Temp\go-build288286770=/tmp/go-build -gno-record-gcc-switches

I'm on windows 7 64bit.

Am I doing something wrong or is this a bug?

pravic commented 5 years ago

The newest Sciter version? It's about the Breaking change then.

rakkele commented 5 years ago

Yes, thank you very much. Adding

sciter.SetOption(sciter.SCITER_SET_SCRIPT_RUNTIME_FEATURES, sciter.ALLOW_SOCKET_IO)

to the beginning of main() makes everything work now.