energye / energy

Energy is a framework developed by Go language based on CEF (Chromium Embedded Framework) for developing cross-platform desktop applications for Windows, Mac OS X, and Linux
https://energye.github.io
Apache License 2.0
380 stars 29 forks source link

Warning: disabling flag --expose_wasm due to conflicting flags #46

Open JSchmidt63 opened 4 days ago

JSchmidt63 commented 4 days ago

go.mod

module main

go 1.23

require ( github.com/energye/energy/v2 v2.4.5 )

require ( github.com/energye/golcl v1.0.12 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c // indirect golang.org/x/sys v0.27.0 // indirect )

and main.go

// or go build -ldflags "-s -w" // with a terminal // then terminal: ./main.exe

package main

import ( "embed" "fmt" "runtime"

"github.com/energye/energy/v2/cef"
"github.com/energye/energy/v2/cef/i18n"

"github.com/energye/energy/v2/consts"
"github.com/energye/energy/v2/logger"

)

//go:embed resources var resources embed.FS

const BrowserVersion = "118-freezed"

func main() { logger.SetEnable(true) logger.SetLevel(logger.LError) fmt.Printf("\nVersion:%s", runtime.Version()) fmt.Printf("\nCompiler:%s", runtime.Compiler) fmt.Printf("\nNo. of CPU:%v\n", runtime.NumCPU()) fmt.Printf("\nGOOS:%s", runtime.GOOS) fmt.Printf("\nGOARCH:%s", runtime.GOARCH) fmt.Printf("\nGOROOT:%s\n", runtime.GOROOT()) fmt.Printf("\nBrowserVersion:%s\n", BrowserVersion)

//global initialization must be called by every application, then create application
cef.GlobalInit(nil, &resources)
cefApp := cef.NewApplication()
fmt.Printf("ChromeBuild:%s\n", cefApp.ChromeVersion())
fmt.Printf("LibVersion:%s\n", cefApp.LibVersion())

cefApp.SetLocale(consts.LANGUAGE_en_US)
cef.BrowserWindow.Config.ChromiumConfig().SetEnableMenu(true) //Enable right-click menu
cef.BrowserWindow.Config.ChromiumConfig().SetEnableDevTools(true) //Enabling Developer Tools

// Set the i18n resource loading method here, use the built-in to exe method here.
i18n.SetLocalFS(&resources, "resources")
i18n.Switch(consts.LANGUAGE_en_US)

//specify a URL address, or a local html file directory
cef.BrowserWindow.Config.Url = "https://html5test.co/"
cef.BrowserWindow.Config.Title = "ENERGY minimal Test"

//run application
cef.Run(cefApp)

}

click at the contextmenu (click right mouse) and choose the "Print Ctrl-P" the look at the terminal: ./main.exe

Version:go1.23.2 Compiler:gc No. of CPU:12

GOOS:windows GOARCH:amd64 GOROOT:C:\Program Files\Go

BrowserVersion:118-freezed ChromeBuild:118.0.5993.119 LibVersion:

Version:go1.23.2 Compiler:gc No. of CPU:12

GOOS:windows GOARCH:amd64 GOROOT:C:\Program Files\Go

BrowserVersion:118-freezed ChromeBuild:118.0.5993.119 LibVersion:

Version:go1.23.2 Compiler:gc No. of CPU:12

GOOS:windows GOARCH:amd64 GOROOT:C:\Program Files\Go

BrowserVersion:118-freezed

Version:go1.23.2 Compiler:gc No. of CPU:12

GOOS:windows GOARCH:amd64 GOROOT:C:\Program Files\Go

BrowserVersion:118-freezed ChromeBuild:118.0.5993.119 LibVersion: ChromeBuild:118.0.5993.119 LibVersion:

Version:go1.23.2 Compiler:gc No. of CPU:12

GOOS:windows GOARCH:amd64 GOROOT:C:\Program Files\Go

BrowserVersion:118-freezed

Version:go1.23.2 Compiler:gc No. of CPU:12

GOOS:windows GOARCH:amd64 GOROOT:C:\Program Files\Go

BrowserVersion:118-freezed ChromeBuild:118.0.5993.119 LibVersion: ChromeBuild:118.0.5993.119 LibVersion:

Version:go1.23.2 Compiler:gc No. of CPU:12

GOOS:windows GOARCH:amd64 GOROOT:C:\Program Files\Go

BrowserVersion:118-freezed

Version:go1.23.2 Compiler:gc No. of CPU:12

GOOS:windows GOARCH:amd64 GOROOT:C:\Program Files\Go

BrowserVersion:118-freezed ChromeBuild:118.0.5993.119 LibVersion: ChromeBuild:118.0.5993.119 LibVersion:

Version:go1.23.2 Compiler:gc No. of CPU:12

GOOS:windows GOARCH:amd64 GOROOT:C:\Program Files\Go

BrowserVersion:118-freezed

Version:go1.23.2 Compiler:gc No. of CPU:12

GOOS:windows GOARCH:amd64 GOROOT:C:\Program Files\Go

BrowserVersion:118-freezed ChromeBuild:118.0.5993.119 LibVersion: ChromeBuild:118.0.5993.119 LibVersion: Warning: disabling flag --expose_wasm due to conflicting flags

in the last line you see the warning

Thanks

sxmxta commented 4 days ago

Hello, I have seen this warning. But I am not familiar with this. I don't know what it can do?

sxmxta commented 4 days ago

demo-link: https://timhutton.github.io/opengl-canvas-wasm Do you open this link in Energy to see if it's correct? Is it the effect you want?

JSchmidt63 commented 4 days ago

The warning is occurring when printing dialog is created. Maybe it is a bug in cef, but i don't know that?

thanks

sxmxta commented 4 days ago

Perhaps this warning has no impact, I am not familiar with it. But I tested several WebAssembly WASM websites and examples, and they all worked fine

Golang WebAssembly (Wasm): https://github.com/maxence-charriere/go-app Use go-app build site :https://go-app.dev/

The website above https://go-app.dev/ Open directly in Energy


Here is an example of Wasm generated by running go app

No obvious abnormalities were found

package main

import (
    "github.com/maxence-charriere/go-app/v10/pkg/app"
    "log"
    "net/http"
)

// hello is a component that displays a simple "Hello World!". A component is a
// customizable, independent, and reusable UI element. It is created by
// embedding app.Compo into a struct.
type hello struct {
    app.Compo
}

// The Render method is where the component appearance is defined. Here, a
// "Hello World!" is displayed as a heading.
func (h *hello) Render() app.UI {
    return app.H1().Text("Hello World!")
}

// The main function is the entry point where the app is configured and started.
// It is executed in 2 different environments: A client (the web browser) and a
// server.
func main() {
    // The first thing to do is to associate the hello component with a path.
    //
    // This is done by calling the Route() function,  which tells go-app what
    // component to display for a given path, on both client and server-side.
    app.Route("/", func() app.Composer { return &hello{} })

    // Once the routes set up, the next thing to do is to either launch the app
    // or the server that serves the app.
    //
    // When executed on the client-side, the RunWhenOnBrowser() function
    // launches the app,  starting a loop that listens for app events and
    // executes client instructions. Since it is a blocking call, the code below
    // it will never be executed.
    //
    // When executed on the server-side, RunWhenOnBrowser() does nothing, which
    // lets room for server implementation without the need for precompiling
    // instructions.
    app.RunWhenOnBrowser()

    // Finally, launching the server that serves the app is done by using the Go
    // standard HTTP package.
    //
    // The Handler is an HTTP handler that serves the client and all its
    // required resources to make it work into a web browser. Here it is
    // configured to handle requests with a path that starts with "/".
    http.Handle("/", &app.Handler{
        Name:        "Hello",
        Description: "An Hello World! example",
    })

    if err := http.ListenAndServe(":8000", nil); err != nil {
        log.Fatal(err)
    }
}

//set GOARCH=wasm
//set GOOS=js
//go build -o web/app.wasm
//go run main.go