Commit Graph

183 Commits

Author SHA1 Message Date
Elias Naur 78565c9232 cmd,example: bump gio version
Updates gio#128

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-07 08:44:41 +02:00
Elias Naur 0749afc13c example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-06 19:31:12 +02:00
Elias Naur a4e572d0e3 cmd,example: gump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05 10:57:08 +02:00
Gordon Klaus 9d2a6c48d8 io/pointer: add InputOp.Types to specify which types of events to receive
Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
2020-06-03 15:29:12 +02:00
Elias Naur fc290f3457 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-02 15:49:16 +02:00
Elias Naur 9196ce0369 cmd,example: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-02 12:20:20 +02:00
Elias Naur eafe09967f cmd,example: bump gio
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-01 00:05:45 +02:00
Elias Naur 2487842aae cmd,example: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-31 12:00:10 +02:00
Elias Naur e9500f5f4c cmd,example: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-30 14:44:02 +02:00
Elias Naur 6a0da04598 cmd,example: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-27 16:41:26 +02:00
Elias Naur 7b6eafcb59 cmd,example: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-27 16:17:22 +02:00
Elias Naur 3164a3fee7 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-24 13:24:13 +02:00
Elias Naur d8000880c3 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-23 23:14:46 +02:00
Elias Naur 60bed57cd7 cmd/gogio: use URL query for passing arguments to wasm programs
The location.hash method doesn't work correctly with multiple
iframes and Safari.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-22 16:22:08 +02:00
Elias Naur fc2a2ae615 cmd,example: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-22 11:35:50 +02:00
Elias Naur 67382bec39 cmd/gogio: [wasm] pass location.hash (if set) to os.Args
Allow for specifying command line arguments to webassembly programs
through the URI hash (https://example.com/wasm/index.html#args)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-21 20:34:11 +02:00
Elias Naur a96b208582 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-21 10:56:44 +02:00
Elias Naur 99080023e4 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-19 10:16:25 +02:00
Elias Naur dc7a8fd9ea example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 19:52:17 +02:00
Daniel Martí 669e4cc96a cmd/gogio: speed up the wine e2e test
First, use wineboot instead of winecfg to set up the WINEPREFIX. It's
the right tool for it.

Second, when initialising WINEPREFIX, use output pipes instead of
CombinedOutput. The latter will wait for *all* output to be copied to a
buffer, including the output from grandchildren processes. Since wine
starts wineserver automatically, and wineserver lingers for three
seconds by default, this is bad. We would waste three seconds waiting
for wineserver doing nothing, and then the next wine call (to start the
app) would need to start wineserver all over.

Instead, with pipes we can get cmd.Run to only wait for the parent
process to finish. wineserver stays running but we don't care. And, when
we start the gio app, we very likely reuse the same wineserver process.

Third, disable wine-gecko and wine-mono. This ensures we don't get stuck
if they're not installed, and speeds up wineboot by avoiding work we
don't need.

The time to set up WINEPREFIX goes down form ~6s to ~1s, and the overall
subtest run-time goes down from ~10s to ~3s.

Finally, copiously document all of the precious data I've gathered above
after hours of debugging.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 21:51:30 +02:00
Daniel Martí 023e022255 cmd/gogio: make e2e test output consistent
Fix a long-standing TODO: instead of each sub-test handling its own
output separately, just make each expose its output via an io.Reader.
Then, the shared driverBase code can tell if any of the lines contain
the magic "gio frame ready" string.

Reduces the amount of code a bit, but most importantly, it keeps the "is
a frame ready?" logic in a single place.

In the future, this also enables us to do more with all the e2e test app
output consistently. For example, we might want to add a -debug flag to
always log output lines as they happen.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 20:32:57 +02:00
Daniel Martí 9ad412ea0b cmd: bump gioui.org dependency, use -modfile properly on CI
A simple 'go test -modfile=<path>' won't work properly for the
end-to-end tests, since they run 'go build' under the hood as well.

To properly propagate the flag, we need to use GOFLAGS. Since -modfile
is always relative to the current directory, we can't use it to test
many packages at once, nor can we use it via 'go test ./gogio'.

While at it, document this distinction in go.local.mod to prevent others
getting confused like I did.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 20:32:53 +02:00
Daniel Martí c2cbcee78d cmd/gogio: use a standalone WINEPREFIX for the wine e2e test
This way, if the user has a custom winecfg, it can't possibly affect the
tests. I was encountering this as DXVK does not work on virtual Xorg
servers (which we use), and Gio thus failed to render on such a
combination.

>From the numbers below, it can be seen that setting up a new WINEPREFIX
takes roughly five seconds:

	$ rm -rf ~/.cache/gio-e2e-wine
	$ go test -run EndToEnd/Windows
	PASS
	ok  	gioui.org/cmd/gogio	16.369s
	$ go test -run EndToEnd/Windows
	PASS
	ok  	gioui.org/cmd/gogio	11.810s

A repeated run still has a slow "wine winecfg /?", for some reason. Add
a TODO since I can see it taking a third of the time on my terminal. I
haven't been able to properly investigate why, unfortunately. As far as
I can tell, winecfg is just faster when run with a terminal instead of
an output buffer. They might use isatty on stdout/stderr.

The overall time to run the wine sub-test is increased from ~5s to ~11s,
but it's worth it to make it run everywhere. It looks like there is
plenty of room as per the TODO above, as winecfg seems to mostly do
nothing. We're also not too worried, as all e2e subtests run in
parallel.

Fixes #106.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 08:40:36 +02:00
Elias Naur 0ad8f85c05 cmd/gogio: add -linkmode flags
For experimenting with https://github.com/golang/go/issues/38918.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-08 08:31:26 +02:00
Elias Naur bcbea7e653 cmd/gogio: fix ldflags overwriting
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-08 08:27:42 +02:00
Elias Naur 681bafce08 cmd/gogio: use filepath for Windows compatibility
Fixes gio#112

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-07 15:52:13 +02:00
Daniel Martí e97adeedd9 app/internal/log: use the app ID as the Android log tag
This way, a Gio app's logs can be filtered uniquely, which wasn't
possible before since the tag "gio" would be the same between gio apps.

Since the app ID is supplied at build time, inject it via a variable
with the linker's help. The variable is only used on Android for now,
but that's OK. It might be useful for other platforms or other internal
packages in the future.

Fixes #84.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-06 08:41:04 +02:00
Daniel Martí ec34eb4919 cmd: add a go.local.mod for development
It's essentially a copy of go.mod, but with the gioui.org module replaed
with the parent directory. Useful when wanting to try a change in the
root module as part of a gogio invocation or end-to-end test, such as
either of the following:

	$ cd cmd; go test -modfile=go.local.mod ./...
	$ cd cmd/gogio; go build -modfile=../go.local.mod

Since go.sum can essentially be shared, and since it seems to work with
the go tool, use a symlink. The way the -modfile flag works, if given
foo.mod, it will use the sum file at foo.sum. The only caveat is that
'go mod tidy -modfile=go.mod.local' will try to remove gioui.org lines,
since that module is replaced. So tidy shouldn't be used with -modfile.

In the future, the only upkeep needed for go.local.mod is to update the
external dependencies to mirror changes in go.mod. This is not automated
nor checked by CI, but it could be in the future if it becomes
repetitive or error-prone.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-06 08:41:00 +02:00
Elias Naur a1166e6652 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-03 21:07:53 +02:00
Elias Naur 133fa45258 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-29 10:08:36 +02:00
Elias Naur 9218df1db7 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-28 14:58:49 +02:00
Elias Naur 84d4800a16 cmd/gogio: match Android window background with default Gio color
While launching an app on Android, the hard-coded theme is used for
the color. That color is by default black, and results in a jarring
transition to the actual app background.

The default Gio color is white, so use that for the theme background
as well.

This change will break for "dark mode" programs and similar.  A future
improvement would be to reflect the actual app background in the theme.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-24 15:59:30 +02:00
Elias Naur cf6e128d48 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-23 21:15:17 +02:00
Elias Naur 2b1935d657 cmd/gogio: include Android themes in .aar outputs
Not strictly necessary, but makes embedding a Gio Android Activity
easier; adding

	<activity android:name="org.gioui.GioActivity"
		android:theme="@style/Theme.GioApp"
		android:configChanges="orientation|keyboardHidden"
		android:windowSoftInputMode="adjustResize">
		<intent-filter>
			<action android:name="android.intent.action.MAIN" />
			<category android:name="android.intent.category.LAUNCHER" />
		</intent-filter>
	</activity>

should be enough.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-18 20:24:42 +02:00
Elias Naur 1a3bbd5d92 example,cmd: update gio
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-01 13:21:55 +02:00
Daniel Martí acfe91ec3e CI: add wine on Linux for the Windows e2e test
Installing it on Debian was enough, with the only wrinkle that
propagating -race won't work when we're cross-compiling, since
cross-compilation disables CGo by default.

For now, just skip the test in that edge case. If we want to use the
race detector on Windows in the future, we need to get a Windows CI
builder somehow.

Tested on my fork; see https://builds.sr.ht/~mvdan/job/164899.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-08 10:52:08 +01:00
Daniel Martí 49000ae4a3 cmd/gogio: add the first Windows e2e test via Wine
Since Wine is heavily tied to X11, we build its end-to-end test driver
on top of X11's. We use the same mechanism to start an X server, take
screenshots, and issue clicks.

Its only quirk is that it was difficult to get the screenshots to line
up with Gio's window. The comments cover what we ended up with. The
display dimensions are now part of driverBase, so that methods other
than Start can also use them - this is necessary for the wine driver to
crop screenshots.

We also use a sleep for now; a comment explains why, and a TODO is left
for future Dan to deal with. What we have now works, and I've spent
enough hours on this patch as it is.

Adding Wine to CI, and ensuring that the test passes there, is left for
a follow-up patch.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-05 09:49:02 +01:00
Daniel Martí 9bbeb92b61 cmd/gogio: reuse the test binary to call gogio in the e2e tests
We were using 'go run . <args>' before, which works fine, but does mean
re-linking a new binary and throwing it away at each invocation. Given
that the end-to-end tests don't do all that much work besides building
the tiny red.go app, this amount of extra work was noticeable.

We can obtain statistics for the JS sub-test, which used 'go run', via
the perflock and benchcmd tools:

	$ go test -c
	$ perflock -governorp% benchcmd EndToEnd/JS ./gogio.test -test.run=EndToEnd/JS

After capturing those numbers before and after the change, we can then
compare them with benchstat. The CPU cost of the subtest is halved:

	name         old time/op         new time/op         delta
	EndToEnd/JS          1.42s ± 2%          1.07s ± 3%  -25.04%  (p=0.008 n=5+5)

	name         old user-time/op    new user-time/op    delta
	EndToEnd/JS          1.46s ± 3%          0.75s ± 5%  -48.34%  (p=0.008 n=5+5)

	name         old sys-time/op     new sys-time/op     delta
	EndToEnd/JS          366ms ±13%          224ms ± 7%  -38.79%  (p=0.008 n=5+5)

An alternative here would have been to refactor main.go to allow being
called directly. However, that would have required a non-trivial
refactor, since flag parsing is done via globals. Given that the
TestMain method is asy and keeps the main function simple, we've
decided to avoid a refactor.

While at it, remove the sleep in the Android driver to wait for the app
to come up on screen. Since we retry screenshots now, we no longer need
a static sleep. On average, we still need one retry for the initial
screenshot, but that's just 100ms versus the old 500ms. The maximum wait
time is also 2s here, which should scale better for slower devices.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-02 17:34:59 +01:00
Daniel Martí b064899967 cmd/gogio: groundwork for Windows e2e tests on Wine
First, move from debian unstable to testing, since sway was promoted to
testing as of earlier this week.

Second, use the --sync option when using xdotool to move an X11 mouse.
This makes the command block until the mouse has finished moving to the
specified location, removing a potential race with the following
'xdotool click' command.

Third, deduplicate some logic into driverBase: tempDir to create a
temporary directory within a test, and needPrograms to skip a test if
the required programs aren't available.

Lastly, split the code that starts the X11 server into a method, so that
the future Wine e2e driver can reuse it. Since Wine is tightly coupled
with X11, we can reuse a good part of the code, including the X11 server
and the xdotool mechanisms.

We also add a TODO to perhaps improve the handling of the app's output
under each of the e2e test cases.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-02 10:29:17 +01:00
Elias Naur 48eb5c666c example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 16:17:27 +01:00
Elias Naur 3738aa43a8 example,cmd: bump gio version 2020-02-29 15:57:27 +01:00
Elias Naur c1048a3a54 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 13:03:20 +01:00
Elias Naur 0160bba020 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 10:53:20 +01:00
Elias Naur 330705a423 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-28 15:24:07 +01:00
Elias Naur 5ae68d2127 example, cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-28 09:59:34 +01:00
Elias Naur 27c77f1baf example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:56:17 +01:00
Daniel Martí f38dbfca54 cmd/gogio: introduce retries with backoff to the e2e tests
Right now, this was badly needed for the wayland subtest, as it seems
like waiting for a frame to be ready wasn't enough for the screenshot to
show what we want. In practice, even if the machine was idle, it could
sometimes take a few extra milliseconds for the app to first appear on
the display.

This was worse when the machine is under stress, which is often the case
with CI. For example, the command below showed a ~20% failure rate on my
laptop with four cores:

	go test -c -o test && stress ./test -test.run EndToEnd/Wayland

Add a generic withRetries helper function, which allows us to keep
trying some action up to a timeout, with sleeps in between that start at
100ms and keep doubling until 2s. The function also logs before each
sleep, in case the user is confused why their test is stuck for
potentially may seconds at once.

Refactor the wantColors function into a separate function that returns
an error, as we can no longer directly report errors via *testing.T. It
still reports all the mismatches at once, which is useful. It can now be
used on to pof withRetries with a thin wrapper.

While at it, make the X11 subtest use withRetries to wait for the X
server to be ready. It was using a simpler method with a fixed number of
static sleeps. It's now more consistent, and a bit better overall.

With the changes above, the 'stress' command from earlier can get past
100 runs on my laptop with no failures at all.

Finally, fix a rogue log.Fatal call I had somehow missed.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-02-10 18:31:53 +01:00
Elias Naur cad51f4d22 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-10 18:25:16 +01:00
Elias Naur 140888ec86 example/glfw: add example demonstrating GLFW integration
Updates gio#26

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 23:15:05 +01:00
Daniel Martí ed8a0c4909 cmd/gogio: extract endtoend driver base into a type
This type contains all the common bits, such as *testing.T, as well as
the channel and method used to wait for blocking until a frame is ready.

It also allows us to initialise this base separately from Start, which
keeps the exported method simpler to understand.

The base type is embedded into the specific driver types, so that the
code remains simple. While at it, start embedding *testing.T too, so
that we can write d.Fatalf instead of d.t.Fatalf. The drivers will only
have a small number of exported methods as per the interface, so it's
easy to keep those from colliding with the method set on T.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-02-06 08:15:32 +01:00