asticode/go-astilectron

win7 startup stuck

rh-08 opened this issue · 11 comments

rh-08 commented

Hi,

I encountered a problem during use, the log is as follows:

NFO: 2023/03/14 21:23:33 loggergo:136: Sending to Astilectron: {"name":"window.cmd.create","targetID":"1","sessionId":"2","url":"C:\ users\user\AppData\Roaming\culture\resources\app\indexhtml","window0ntions":{"backgroundColor":"#5F5F5","center":true,"fullscreen":true,"icon":"C:\ users\user\AppData\Roaming\culture\resources\icon.png","title":"culture"}}
INFO: 2023/03/14 21:23:34 logger.go:136: Astilectron says: {"name":"window.event.focus”,"targetiD":"1"}
INF0: 2023/03/14 21:23:42 loggergo:136: Astilectron says: {"name":"window .event.resize","targetID":"1","bounds":{"x":0,"y":0,"width":1280","height":1023}}
INFO: 2823/03/14 21:23:42 loggergo:136: Astilectron says: {"name";"window .event.blur","targetID":"1"}

The program hangs when it runs here, and the window is a white screen. Please help me, thank you!!

operating system:win7 32;

err := bootstrap.Run(bootstrap.Options{
Asset: Asset,
AssetDir: AssetDir,
AstilectronOptions: astilectron.Options{
AppName: AppName,
AppIconDarwinPath: "resources/icon.icns",
AppIconDefaultPath: "resources/icon.png",
AcceptTCPTimeout: time.Second * 60,
},
Debug: *debug,
Logger: logger.Info,
RestoreAssets: RestoreAssets,
OnWait: func(_ *astilectron.Astilectron, ws []*astilectron.Window, _ *astilectron.Menu, _ *astilectron.Tray, _ *astilectron.Menu) error {
m.Window = ws[0]
go func() {
time.Sleep(time.Second * 5)

		}()
		return nil
	},
	Windows: []*bootstrap.Window{{
		Homepage:       "index.html",
		MessageHandler: handler.handleMessages,
		Options: &astilectron.WindowOptions{
			BackgroundColor: astikit.StrPtr("#F5F5F5"),
			Center:          astikit.BoolPtr(true),
			Fullscreen:      astikit.BoolPtr(true),
		},
	}},
})

if err != nil {
	logger.Error.Printf("start error: %v\r\n", err)
}

e57a21e4761097026c96d1249793c83

Have you tried setting height and width to your window instead of using fullscreen?

rh-08 commented

Hi,
I set the height and width, but it still happens occasionally.

             Windows: []*bootstrap.Window{{
		Homepage:       "index.html",
		MessageHandler: handler.handleMessages,
		Options: &astilectron.WindowOptions{
			BackgroundColor: astikit.StrPtr("#F5F5F5"),
			Center:          astikit.BoolPtr(true),
			//Fullscreen:      astikit.BoolPtr(true),
			Height: astikit.IntPtr(1024),
			Width:  astikit.IntPtr(1280),
		},
	}},

20fca0ba10938592b0849e7413dd165

If this happens, just close the window and restart it?

Thank you !!

What are the logs when everything works fine?

rh-08 commented

Hi,

The log when opening the window normally is:

INFO: 2023/03/21 19:56:52 logger.go:147: astikit: starting worker...
INFO: 2023/03/21 19:56:52 logger.go:135: Skipping restoring resources...
INFO: 2023/03/21 19:56:52 logger.go:135: Starting...
INFO: 2023/03/21 19:56:52 logger.go:135: Provisioning...
INFO: 2023/03/21 19:56:52 logger.go:136: Astilectron has already been provisioned to version 0.55.0, moving on...
INFO: 2023/03/21 19:56:52 logger.go:136: Electron has already been provisioned to version 11.4.3, moving on...
INFO: 2023/03/21 19:56:52 logger.go:135: Listening...
INFO: 2023/03/21 19:56:52 logger.go:135: Executing...
INFO: 2023/03/21 19:56:52 logger.go:136: Starting cmd C:\Users\user\AppData\Roaming\culture\vendor\electron-windows-386\electron.exe C:\Users\user\AppData\Roaming\culture\vendor\astilectron\main.js 127.0.0.1:49162 false
INFO: 2023/03/21 19:56:53 logger.go:136: Stdout says:
INFO: 2023/03/21 19:56:53 logger.go:136: Astilectron says: {"name":"app.event.ready","targetID":"app","displays":{"all":[{"id":2528732444,"bounds":{"x":0,"y":0,"width":1280,"height":1024},"workArea":{"x":0,"y":0,"width":1280,"height":984},"accelerometerSupport":"unknown","monochrome":false,"colorDepth":24,"colorSpace":"{primaries:BT709, transfer:IEC61966_2_1, matrix:RGB, range:FULL}","depthPerComponent":8,"size":{"width":1280,"height":1024},"workAreaSize":{"width":1280,"height":984},"scaleFactor":1,"rotation":0,"internal":true,"touchSupport":"unknown"}],"primary":{"id":2528732444,"bounds":{"x":0,"y":0,"width":1280,"height":1024},"workArea":{"x":0,"y":0,"width":1280,"height":984},"accelerometerSupport":"unknown","monochrome":false,"colorDepth":24,"colorSpace":"{primaries:BT709, transfer:IEC61966_2_1, matrix:RGB, range:FULL}","depthPerComponent":8,"size":{"width":1280,"height":1024},"workAreaSize":{"width":1280,"height":984},"scaleFactor":1,"rotation":0,"internal":true,"touchSupport":"unknown"}},"supported":{"notification":true}}
INFO: 2023/03/21 19:56:53 logger.go:136: Sending to Astilectron: {"name":"window.cmd.create","targetID":"1","sessionId":"2","url":"c:\Users\user\AppData\Roaming\culture\resources\app\index.html","windowOptions":{"backgroundColor":"#F5F5F5","center":true,"height":1024,"icon":"C:\Users\user\AppData\Roaming\culture\resources\icon.png","title":"culture","width":1280}}
INFO: 2023/03/21 19:56:53 logger.go:136: Astilectron says: {"name":"window.event.focus","targetID":"1"}
INFO: 2023/03/21 19:56:54 logger.go:136: Astilectron says: {"name":"window.event.did.finish.load","targetID":"1","bounds":{"x":0,"y":0,"width":1280,"height":984}}
INFO: 2023/03/21 19:56:54 logger.go:136: Astilectron says: {"name":"window.event.ready.to.show","targetID":"1"}
INFO: 2023/03/21 19:56:54 logger.go:147: astikit: worker is now waiting...

It's weird since when it's not working, it's not receiving the did.finish.load window event, as if the content in your window couldn't load properly 🤔

rh-08 commented

Haha, it's very weird, is there a way to solve it?

I don't really see one to be honest 🤔 Astilectron is waiting for an event that should come from Electron, but it never arrives 🤔 If closing the window and retrying is an option, that's your best solution 👍

rh-08 commented

Thank you!

rh-08 commented

Hi,

I updated the version of Electron to 20.1.4 to solve the above problem, but occasionally when closing the window:

A javascript error occurred in the main process
Uncaught Exception:
Error: read ECONNRESET
at TCP.onStreamRead (node:internal/stream base commons:217:20)

e2a1afbc70bf92bd0412a8322a6a2aa

If you run your program through the terminal and you enable debug logs, terminal might show more information 🤔

rh-08 commented

I found a bug with the code in the debug logs, the problem has been resolved.

Thank you very much !!!