Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing Mattermost sends it crazy #2509

Closed
AlanGriffiths opened this issue Jul 18, 2022 · 4 comments
Closed

Resizing Mattermost sends it crazy #2509

AlanGriffiths opened this issue Jul 18, 2022 · 4 comments

Comments

@AlanGriffiths
Copy link
Collaborator

  1. Open the mattermost-desktop snap on a Mir compositor (without hacking it to use Wayland)
  2. Try to resize it's window

Expect: window resizes
Actual: window disappears and mattermost hogs a CPU

(This doesn't occur using Wayland, so is likely to do with our Xwayland interaction)

@mattkae
Copy link
Contributor

mattkae commented Sep 21, 2023

Note that this even happens when we fullscreen the mattermost application

@mattkae
Copy link
Contributor

mattkae commented Sep 21, 2023

Fun fact: It does not disappear: it just gets a teeny tiny width and height. The very tiny black bar on the left hand side of this image is mattermost:
Screenshot from 2023-09-21 15-02-36

@mattkae
Copy link
Contributor

mattkae commented Sep 21, 2023

The problem is that the WindowInfo::max_width/max_height are both 1. Time to figure out why 🥾

UPDATE:
The offending lines are:

#define SCALE_SIZE(type, prop) \
    if (mods.prop) \
    { \
        mods.prop = std::max(geom::type{1}, mods.prop.value() * inv_scale); \
    }
...
SCALE_SIZE(Width, max_width);
SCALE_SIZE(Height, max_height);

in XWaylandSurface::prep_surface_spec. max_width and max_height are both set to 32bit int max here

UPDATE, UPDATE:
That's a fun one. So what's going on here (AFAICT)? Let's take max_width as the example:

  • max_width is type Width<int> which is just a Value<int> under the hood
  • It is asked to be scaled by inv_scale, which is a float set to 1.f, which makes the value resulting from the multiplication be 2.14748365e+09
  • This number then gets cast back to an int because the multiplication wants to return the initial int type, which results in -2147483648, which is obviously less than 1.

TLDR; this is happening:

#include <iostream>
#include <algorithm>

int main()
{
    int x = 2147483647;
    int y = static_cast<int>(x * 1.f);
    int z = std::max(1, y);
    std::cout << y << ", " << z << std::endl;
    return 0;
}
  • y is -2147483648,
  • z is 1

@mattkae
Copy link
Contributor

mattkae commented Sep 22, 2023

Fixed by #3050

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants