wails: Cannot set size of window on Ubuntu 22.04 (heigh and width is 0)

Description

When running wails, both in dev and build mode on Ubuntu, the height and width are zero. I ran the same exact code on MacOS and it works.

It’s stuck at (seemingly) 0 width and 0 height. If you pass it the Fullscreen argument in app initialization, or call runtime.WindowFullscreen(ctx) from go, you still start off with 0 widht and 0 height, but it becomes resizable via the GUI.

OS Version:

Distributor ID:	Ubuntu
Description:	Ubuntu 22.04 LTS
Release:	22.04
Codename:	jammy

To Reproduce

Initialize project: wails init -n wails_issue_repro -t react-ts Run wails dev or run wails build and execute build executable

Expected behaviour

Window respects size of initial app config and is programatically resizable.

Screenshots

image

Attempted Fixes

Search through github and did not find any fixes or same issues

System Details

~/tmp/wails-issue-repro/wails_issue_repro$  wails doctor
Wails CLI v2.0.0-beta.38


Scanning system - Please wait (this may take a long time)...Done.

System
------
OS:		Ubuntu
Version: 	22.04
ID:		ubuntu
Go Version:	go1.18.1
Platform:	linux
Architecture:	amd64

Wails
------
Version: 		v2.0.0-beta.38
Package Manager: 	apt

Dependency	Package Name		Status		Version
----------	------------		------		-------
*docker		docker.io		Installed	20.10.17
gcc		build-essential		Installed	11.2.0
libgtk-3	libgtk-3-dev		Installed	3.24.33-1ubuntu2
libwebkit	libwebkit2gtk-4.0-dev	Installed	2.36.3-0ubuntu0.22.04.1
npm		npm			Installed	8.5.1~ds-1
*nsis		nsis			Installed	v3.08-2
pkg-config	pkg-config		Installed	0.29.2

* - Optional Dependency

Diagnosis
---------
Your system is ready for Wails development!


If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 42 (39 by maintainers)

Most upvoted comments

I’m on vacation without internet. Will look at this next week!

@leaanthony

Thanks everyone for the amazing testing and feedback! This is now merged 🙏

Did you use replace to use the branch?

I did git clone https://github.com/wailsapp/wails --branch=bugfix/linux_scaling_issues and cd wails/v2/cmd/wails && go install

Go projects need to update go.mod if you want to use non-module code: wails.io/docs/guides/bleeding-edge

Thank you. It works now.

Thanks for the quick response @leaanthony , the fix mentioned in your comment here #1420 (comment) did not work for me (as per the commentor’s follow up, I ensured the the environment variabl wasn’t set in any other way as well). However, I did find a different workaround in the meantime. If you call runtime.WindowSetMaxSize(ctx, 100000, 100000) it allows you to subsuquently call runtime.WindowSetSize(ctx,500,500) (or whatever values you want there). However, it does not let you call other API’s, such as runtime.WindowMaximise(ctx) or runtime.WindowFullscreen(ctx) Strangely, if you set up your App with large MaxHeight and MaxWidth properties, all API’s that I’ve tested work.

err := wails.Run(&options.App{
		Title: "learn-wails",
		MaxHeight:        100000,
		MaxWidth:         100000,
		Width:            500,
		Height:           1500,
		Assets:           assets,
		OnDomReady:       app.OnDomReady,
		BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
		OnStartup:        app.startup,
		Bind: []interface{}{
			app,
		},
	})

This seems to be a genuine workaround. It works properly when MaxHeight and MaxWidth are set

This method solved my problem,But I think it’s a scaling issue ubuntu:setting->screen display->scale:100%

Works on a fresh installation of Ubuntu 22.04. This is likely an issue when upgrading from 21.10 to 22.04.

Thanks so much for taking the time to look at this @ianmjones ❤️ 👍 🚀

I never checked the value of XDG_SESSION_TYPE. Maybe it’s wonky? I’ll check it out when I’m on my personal computer next.