fixed #387 - Setting viewport isn't quite synchronous