Skip to content

[Bug] My frame keeps moving on re-log. #69

@rainx0r

Description

@rainx0r

Describe the bug
What it says on the tin. My raid / party frames keep moving. Through debugging, I found this is always exactly 5 pixels off on each dimension each re-log. Say my frames are on PosX = -93, PosY=76, anchor="BOTTOMRIGHT", next re-log this will be -88, 71.

For whatever reason, this ONLY happens when re-logging, not when reloading.

To Reproduce
I can give you my profile / SavedVariables and other things upon request,

I did manage to do a band-aid fix, but I'd like to use this issue to describe to you my scenario, testing and poking around work, and hopefully since you know your codebase better than me maybe you can derive some better, generally applicable solution!

The scenario

  • Prior: I used to use Grid1, moved over to Plexus around BFA or Shadowlands, don't remember. My original UI was made for 1080p, I'm now on 1440p.
  • The environment: Game running natively at 1440p, UI is at 80% scale (UIParent:GetEffectiveScale() = 0.79999995231628). Note that this is also the value of PlexusLayoutFrame:GetEffectiveScale()

Every time I re-log, the following things happen:

  • PlexusLayout:PostEnable() gets triggered.
  • This calls PlexusLayout:RestorePosition() which reads the PosX, PosY, anchor from the profile, divides them by the scale and rounds up, then sets the position. Up to here, according to my logs, everything seems to work fine. This function reads the correct values, the conversion looks correct, and it restores my UI to the correct position, if I comment out everything that happens after this function.
  • Then PlexusLayout:Scale() gets called which:
    • Calls PlexusLayout:SavePosition(), which is where things seem to go wrong according to my logs. If I check what profile.PosX / profile.PosY is at the beginning of this function, it's the value RestorePosition() set. However, the value that gets saved back to the profile in that last if statement is 5 pixels off. This means the value retrieved from all the calculations in the anchor if chain is actually somehow 5 pixels off.
    • RestorePosition() gets called again, this time placing my frame in the incorrect position of 5 pixels off. This position then gets saved to my SavedVariables when I log out. Since every time a value 5 pixels off gets saved, my frame moves eternally every re-log.

My "band-aid" fix
In PlexusLayout:SavePosition()

    ...
    if x and y and s then
        x, y = floor(x - 5 + 0.5), floor(y + 5 + 0.5)
        self.db.profile.PosX = x
        self.db.profile.PosY = y
        ...
    end

For whatever reason, this fixes the problem on re-log, and the values that get saved agree with the values there before / the ones RestorePosition originally used when loading the frame, and my frame does not move every re-log any more.

But then the problem starts happening on /reload instead. The problem did not happen on /reload before. However, this demonstrates that it's literally just 5 pixels off.

My second fix was this:
PlexusLayout:PostEnable()

    -- position and scale frame
    self:RestorePosition()
    -- self:Scale()
    self.frame:SetScale(self.db.profile.scale)
    self:RestorePosition()

Now the frame works perfectly both on re-log and reload.

Potential clues

  • Maybe this is a quirk of Blizzard's UI code and how they handle different scales / resolutions, especially on re-log. For whatever reason, when you set the position with RestorePosition() but then try to re-infer its coordinates in SavePosition() immediately after (as in the flow introduced by PostEnable()), maybe you get 5 pixel off values for whatever reason.
  • When you really think about it though, there is no reason for this flow, since you just set the frame's position programmatically, so it has no chance of changing position, making the problematic SavePosition() call redundant. As far as I can tell with my fix everything works as expected.

Desktop (please complete the following information):

  • OS: Windows 11
  • Version: 2.4.7 (But Layout.lua, where the bug is, has not changed in 2.4.9)
  • Game Version: 10.0.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions