shiny/driver/gldriver: initialize glctx fields earlier.

A *windowImpl's glctx and worker fields should really be set on
construction (and never modified afterwards), as fields in the
&windowImpl{ etc } literal during screenImpl.NewWindow. However, the
initialization values are platform specific, so they are initialized in
a separate function call.

Until now, that function call was showWindow, as it is called
conveniently soon after newWindow returns. showWindow's primary purpose
is mostly unrelated: to show the freshly created window on the screen.

Soon isn't soon enough, though. The (implemented in C) message pump
happens in another thread, which can trigger callbacks like onConfigure,
which (racily) reads the w.glctx field with lines like:

w.lifecycler.SendEvent(w, w.glctx)

This commit fixes the race, originally reported at

Change-Id: I69d50b037ec4c4f021ca60f570f86723c17d7bb7
Reviewed-by: David Crawshaw <>
5 files changed