Skip to content

BlazorGL Window ClientBounds are incorrect on initial load on iOS #2553

@dtaylorus

Description

@dtaylorus

The attached images show a BlazorGL game rendered in Safari on iOS. The red rectangle should be completely visible around the edge of the browser viewport.

The first image shows the rectangle cut off at the bottom when the game is initially loaded due to the client bounds being too large.

The second image shows the full red rectangle inside the viewport as expected after rotating the device to landscape orientation and back to portrait, which triggers a window resize that fixes the window client bounds.

As a workaround, you can invoke BlazorGameWindow.OnResize on game initialization, e.g.:

((BlazorGameWindow)this.Window).OnResize(null)

The OnResize method is internal, so you can invoke it via reflection, e.g.,:

var windowOnResizeMethod = ((BlazorGameWindow)this.Window).GetType().GetMethod(@"OnResize", BindingFlags.NonPublic | BindingFlags.Instance, [typeof(object)]);
windowOnResizeMethod.Invoke(this.Window, [null]);

Note that the same issue exists on Chrome for iOS as well.

Incorrect Correct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions