asticode / go-astilectron-bundler

Bundle your Astilectron app with ease

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing Resources

roociferSonOfTheMorning opened this issue · comments

Similar to: #87

Building in Ubuntu:
astilectron-bundler cc && astilectron-bundler -w

$ cat bundler.json
{
  "app_name":"testApp",
  "icon_path_linux": "resources/icon.png",
  "icon_path_windows": "resources/icon.ico",
  "version_astilectron": "0.37.0",
  "version_electron": "8.2.0"
}
$ ls ./resources/app/js
app.4aa14500.js
app.4aa14500.js.map
chunk-vendors.a69e73a7.js
chunk-vendors.a69e73a7.js.map
$ ls /tmp/astibundler/bind/resources/app/js
app.4aa14500.js
app.4aa14500.js.map
chunk-vendors.a69e73a7.js
chunk-vendors.a69e73a7.js.map

From Windows:
When I download the executable and run it:
Not allowed to load local resource: file:///D:/Users/${me}/AppData/Roaming/testApp/resources/app/index.html

D:/Users/${me}/AppData/Roaming/testApp/vendor exists but resources does not.

Similar issue when I build for linux.

I've several questions :

  • could paste output of ls ./resources/app to see whether index.html exists?
  • did you add ${me} in D:/Users/${me}/AppData/Roaming/testApp/vendor for Github issues or is it the actual path it's trying to load?
  • can you try running the windows executable from the terminal and paste the output here?
background.png  css  favicon.ico  icon.png  index.html  js  main.css

I added ${me}

Running from the terminal launches the app but doesn't log anything more.

Here is my logger in main.go

// Application Vars
var (
	fs    = flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
	debug = false // fs.Bool("debug", false, "enables the debug mode")
	w     *astilectron.Window
)

func main() {
	// Create logger
	l := log.New(log.Writer(), log.Prefix(), log.Flags())

	// Parse flags
	fs.Parse(os.Args[1:])

       ...

Thank you for looking into this.

Are you providing the logger to the boostrap options like here ?

yes I am,

...,
		Debug:  debug,
		Logger: l,
		MenuOptions: []*astilectron.MenuItemOptions{{
...

What logs are you getting on linux when you run the binary from the terminal ?

2021/07/26 15:50:36 Running app built at 2021-07-26 15:23:35.566987934 +0000 UTC m=+7.368436612
2021/07/26 15:50:36 astikit: starting worker...
2021/07/26 15:50:36 Starting...
2021/07/26 15:50:36 Provisioning...
2021/07/26 15:50:36 Astilectron has already been provisioned to version 0.37.0, moving on...
2021/07/26 15:50:36 Electron has already been provisioned to version 8.2.0, moving on...
2021/07/26 15:50:36 Listening...
2021/07/26 15:50:36 Executing...
2021/07/26 15:50:36 Starting cmd /home/me/Development/testApp/output/linux-amd64/vendor/electron-linux-amd64/electron /home/me/Development/testApp/output/linux-amd64/vendor/astilectron/main.js 127.0.0.1:45509 true
2021/07/26 15:50:36 Astilectron says: {"name":"app.event.ready","targetID":"app","displays":{"all":[{"id":168,"bounds":{"x":0,"y":0,"width":1440,"height":900},"workArea":{"x":0,"y":31,"width":1440,"height":820},"accelerometerSupport":"unknown","monochrome":false,"colorDepth":24,"colorSpace":"{primaries:INVALID, transfer:INVALID, matrix:INVALID, range:INVALID}","depthPerComponent":8,"size":{"width":1440,"height":900},"workAreaSize":{"width":1440,"height":820},"scaleFactor":1,"rotation":0,"internal":false,"touchSupport":"unknown"}],"primary":{"id":168,"bounds":{"x":0,"y":0,"width":1440,"height":900},"workArea":{"x":0,"y":31,"width":1440,"height":820},"accelerometerSupport":"unknown","monochrome":false,"colorDepth":24,"colorSpace":"{primaries:INVALID, transfer:INVALID, matrix:INVALID, range:INVALID}","depthPerComponent":8,"size":{"width":1440,"height":900},"workAreaSize":{"width":1440,"height":820},"scaleFactor":1,"rotation":0,"internal":false,"touchSupport":"unknown"}},"supported":{"notification":true}}
2021/07/26 15:50:36 Sending to Astilectron: {"name":"window.cmd.create","targetID":"1","sessionId":"2","url":"file:///home/me/Development/testApp/output/linux-amd64/resources/app/index.html","windowOptions":{"backgroundColor":"#333333","center":true,"height":1000,"icon":"/home/me/Development/testApp/output/linux-amd64/resources/icon.png","resizable":true,"title":"TestApp","width":1200}}
2021/07/26 15:50:36 Stderr says: (electron) The default value of app.allowRendererProcessReuse is deprecated, it is currently "false". It will change to be "true" in Electron 9. For more information please check electron/electron#18397
2021/07/26 15:50:36 Astilectron says: {"name":"window.event.move","targetID":"1"}
2021/07/26 15:50:36 Astilectron says: {"name":"window.event.resize","targetID":"1"}
2021/07/26 15:50:36 Astilectron says: {"name":"window.event.focus","targetID":"1"}
2021/07/26 15:50:36 Astilectron says: {"name":"window.event.did.finish.load","targetID":"1"}
2021/07/26 15:50:36 Sending to Astilectron: {"name":"menu.cmd.create","targetID":"3","menu":{"id":"3","items":[{"id":"4","options":{"label":"File"},"rootId":"app","submenu":{"id":"5","items":[{"id":"6","options":{"label":"Settings"},"rootId":"app"},{"id":"7","options":{"label":"About"},"rootId":"app"},{"id":"8","options":{"role":"close"},"rootId":"app"}],"rootId":"app"}}],"rootId":"app"}}
2021/07/26 15:50:36 Astilectron says: {"name":"menu.event.created","targetID":"3"}
2021/07/26 15:50:36 astikit: worker is now waiting...
2021/07/26 15:50:38 Astilectron says: {"name":"window.event.blur","targetID":"1"}
2021/07/26 15:50:38 Sending to Astilectron: {"name":"window.cmd.web.contents.open.dev.tools","targetID":"1"}

OK so this is working in linux?

for both windows and linux the application will launch, but the app is blank and within the console I can see that it fails to load index.html

For Linux: /home/me/Development/testApp/output/linux-amd64/resources/ does not get created
For Windows: D:/Users/me/AppData/Roaming/testApp/resources does not get created.

In Linux if I create a symbolic link:
$ ln -svf /tmp/astibundler/bind/resources ./output/linux-amd64/resources
then the application works.

It seems to me that something is going wrong when resources is bound to the executable or when the resources folder is created by the executable. I tried to figure out where/how those things happen but haven't been able to yet.

In logs, between astikit: starting worker... and Starting... there should be a step where resources are disembedded, this is really weird 🤔 Can you paste your full func main() code?

I am so sorry for taking up your time. I had commented out: RestoreAssets: RestoreAssets, because it was failing go vet in my test script. I have added it back in and resources is building correctly. Thank you so much for your help!

No worries, glad it's working now ❤️