From aca47d69fd449a0f6a68111941edeef0a033020b Mon Sep 17 00:00:00 2001 From: NoM0Re <1629787+nom0re@users.noreply.github.com> Date: Wed, 24 Dec 2025 03:38:25 -0700 Subject: [PATCH] (fix/WeakAuras) BandAid: Limit frame levels to prevent exceeding UI restrictions #85 Implemented a hard cap for frame level assignments (max 126) across multiple modules, including WeakAuras core logic and AceGUI widget prototypes. The WotLK engine utilizes a signed 8-bit integer for frame levels. Values exceeding 127 cause an overflow. Previously, many frames were inadvertently stacked at or beyond 128, which remained largely unnoticed but caused significant rendering overhead. This got introduced on WeakAuras 4.0 with nested groups, years ago. On newer Clients the FrameLevels are capped at 10000 which makes this system operate smoothly on those clients. A larger fix will be needed in the future. This change prevents the renderer from becoming overwhelmed at maximum depth, particularly when Blizzard UI frames with SetTopLevel(true) are toggled. Capping the values at 126 ensures that there is always a 1-bit buffer before the overflow point, allowing high-priority frames to render smoothly without depth conflicts. (cherry picked from commit 629a45095b10b801573b2cc84d64b6b5a6c1a890) --- WeakAuras/Templates.lua | 8 ++++---- WeakAuras/WeakAuras.lua | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WeakAuras/Templates.lua b/WeakAuras/Templates.lua index eb9d9fe..60a22e4 100644 --- a/WeakAuras/Templates.lua +++ b/WeakAuras/Templates.lua @@ -225,7 +225,7 @@ WeakAuras.XMLTemplates = { -- NineSlice Borders local nineSlice = CreateFrame("Frame", nil, frame) nineSlice:SetAllPoints(frame) - nineSlice:SetFrameLevel(125) + nineSlice:SetFrameLevel(123) frame.NineSlice = nineSlice -- Top Left Corner local topLeftCorner = nineSlice:CreateTexture(nil, "OVERLAY") @@ -315,7 +315,7 @@ WeakAuras.XMLTemplates = { titleContainer:SetSize(0, 20) titleContainer:SetPoint("TOPLEFT", frame, "TOPLEFT", 58, -1) titleContainer:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -24, -1) - titleContainer:SetFrameLevel(126) + titleContainer:SetFrameLevel(124) frame.TitleContainer = titleContainer -- Title Text local titleText = titleContainer:CreateFontString(GetParentName(frame) .. "TitleText", "OVERLAY", "GameFontNormal") @@ -329,7 +329,7 @@ WeakAuras.XMLTemplates = { local closeButton = CreateFrame("Button", nil, frame, "UIPanelCloseButton") closeButton:SetSize(24, 24) closeButton:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, 0) - closeButton:SetFrameLevel(128) + closeButton:SetFrameLevel(126) frame.CloseButton = closeButton closeButton:SetNormalTexture("Interface\\AddOns\\WeakAuras\\Media\\Textures\\redbutton2x") closeButton:GetNormalTexture():SetTexCoord(0.152344, 0.292969, 0.0078125, 0.304688) @@ -383,7 +383,7 @@ WeakAuras.XMLTemplates = { -- MaximizeMinimizeButtonFrameTemplate (Retail 11.1.7 (61967)) ["MaximizeMinimizeButtonFrameTemplate"] = function(frame) frame:SetSize(24, 24) - frame:SetFrameLevel(127) + frame:SetFrameLevel(125) -- Maximize Button local maximizeButton = CreateFrame("Button", "MaximizeButton", frame) diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index a8f6cfb..d436ed1 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -4161,6 +4161,7 @@ end Private.frameLevels = {}; local function SetFrameLevel(id, frameLevel) + frameLevel = math.min(120, frameLevel) if (Private.frameLevels[id] == frameLevel) then return; end