Windows rotated screen and resolution

Hello all,

I am currently having hard time dealing with the rotation system of Windows hybrid tablets.

When the screen rotates, the application (playing in fullscreen) is correctly rotated, and change its resolution so as to fit the height of the tablet. Then, when you rotate the screen back in landscape mode, the application keeps the last resolution used when it was in portrait mode. And when I restart the game, the last “broken” resolution is used

Here is a little piece of code I try to make in order to fix the problem (only to fix the bad ratio in step 2). I can’t rely on the Screen size nor Screen.orientation (the returned values are incorrect)… I use the max resolution instead.

    private void SetMaxResolution()
    {
        currentResolution = Screen.currentResolution;
        maxResolution     = Screen.resolutions[Screen.resolutions.Length - 1];
        currentRatio      = currentResolution.width / ( (float) currentResolution.height );
        maxRatio          = maxResolution.width / ( (float) maxResolution.height );
        screenWidth       = Screen.width;
        screenHeight      = Screen.height;

        if ( Mathf.Abs( currentRatio - maxRatio ) > 0.01f )
        {
            Screen.SetResolution( maxResolution.width, Mathf.RoundToInt( maxResolution.width / maxRatio ), true );
        }
    }

Hi, this issue still exists in unity 2018.2.14.f1
I was able to find a workaround for this by fixing the rotation to Landscape only.
Method to do this is described here :
https://stackoverflow.com/questions/34086474/enforce-landscape-orientation-on-windows-8-1-for-unity-project
Tested and working on Windows 10.