-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebug.lua
More file actions
392 lines (340 loc) · 15.2 KB
/
Copy pathDebug.lua
File metadata and controls
392 lines (340 loc) · 15.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
---@diagnostic disable: undefined-field
local _, ns = ...
local AceGUI = LibStub("AceGUI-3.0")
-------------------------------------------------------------------------------
-- Counter storage
-------------------------------------------------------------------------------
local counters = {
-- Pipeline
hookFires = 0,
queueAttempts = 0,
queueAdds = 0,
queueSkipsDuplicate = 0,
queueSkipsDisabled = 0,
batchCycles = 0,
batchFramesTotal = 0,
peakBatchSize = 0,
frameUpdates = 0,
earlyExits = 0,
retryAttempts = 0,
retrySuccesses = 0,
retryDrops = 0,
-- Caches
barCreates = 0,
barReuses = 0,
anchorModeChanges = 0,
nativeBarsSuppressed = 0,
-- Styling
colorApplied = 0,
colorSkipped = 0,
textureApplied = 0,
textureSkipped = 0,
blendApplied = 0,
blendSkipped = 0,
contextDisabled = 0,
framesShown = 0,
framesHidden = 0,
fullRefreshes = 0,
lastRefreshTime = 0,
poolPath = "none",
poolFramesProcessed = 0,
-- Hibernate
hibernateEvals = 0,
hibernateTransitions = 0,
}
-- Window-scoped counters mirror the same keys (reset on window open)
local windowCounters = {}
local function ResetTable(t, source)
for k in ns.pairs(source) do
local v = source[k]
if type(v) == "number" then
t[k] = 0
elseif type(v) == "string" then
t[k] = ""
end
end
end
ResetTable(windowCounters, counters)
-------------------------------------------------------------------------------
-- Increment helper — bumps both session and window counters
-------------------------------------------------------------------------------
local function Inc(key, amount)
amount = amount or 1
counters[key] = counters[key] + amount
windowCounters[key] = windowCounters[key] + amount
end
local function Set(key, value)
counters[key] = value
windowCounters[key] = value
end
local function Max(key, value)
if value > counters[key] then counters[key] = value end
if value > windowCounters[key] then windowCounters[key] = value end
end
-------------------------------------------------------------------------------
-- Public increment API (called from instrumentation sites)
-------------------------------------------------------------------------------
local Debug = {}
ns.Debug = Debug
Debug.Inc = Inc
Debug.Set = Set
Debug.Max = Max
Debug.counters = counters
Debug.windowCounters = windowCounters
-------------------------------------------------------------------------------
-- Snapshot helpers
-------------------------------------------------------------------------------
local function CountTable(t)
local n = 0
for _ in ns.pairs(t) do n = n + 1 end
return n
end
local function CountFramesByContext(cache)
local party, raid, pet, other = 0, 0, 0, 0
for frame in ns.pairs(cache) do
local unit = frame.displayedUnit
if unit then
if string.find(unit, "pet", 1, true) then
pet = pet + 1
elseif string.find(unit, "raid", 1, true) then
raid = raid + 1
elseif string.find(unit, "party", 1, true) then
party = party + 1
else
other = other + 1
end
end
end
return party, raid, pet, other
end
local function FormatDual(sessionVal, windowVal)
return tostring(sessionVal) .. " (+" .. tostring(windowVal) .. ")"
end
local function FormatRatio(applied, skipped)
return tostring(applied) .. " / " .. tostring(skipped)
end
local function FormatTimestamp(t)
if t == 0 then return "never" end
return string.format("%.1fs ago", ns.GetTime() - t)
end
-------------------------------------------------------------------------------
-- AceGUI Window
-------------------------------------------------------------------------------
local debugFrame = nil
local refreshTicker = nil
--- Creates a labeled row with tooltip.
-- @param parent AceGUI container to add the label to
-- @param labelText Display label (left side)
-- @param tooltipText Tooltip shown on hover
-- @return AceGUI InteractiveLabel widget (call SetText on .valueLabel to update)
local function AddRow(parent, labelText, tooltipText)
local row = AceGUI:Create("SimpleGroup")
row:SetLayout("Flow")
row:SetFullWidth(true)
local label = AceGUI:Create("InteractiveLabel")
label:SetWidth(175)
label:SetText("|cff888888" .. labelText .. "|r")
label:SetFontObject(GameFontHighlightSmall)
if tooltipText then
label:SetCallback("OnEnter", function(widget)
GameTooltip:SetOwner(widget.frame, "ANCHOR_RIGHT")
GameTooltip:AddLine(labelText, 1, 0.82, 0)
GameTooltip:AddLine(tooltipText, 1, 1, 1, true)
GameTooltip:Show()
end)
label:SetCallback("OnLeave", function()
GameTooltip:Hide()
end)
end
row:AddChild(label)
local value = AceGUI:Create("Label")
value:SetWidth(75)
value:SetText("")
value:SetFontObject(GameFontHighlightSmall)
row:AddChild(value)
parent:AddChild(row)
return value
end
local function AddSectionHeader(parent, text)
local heading = AceGUI:Create("Heading")
heading:SetText(text)
heading:SetFullWidth(true)
parent:AddChild(heading)
end
local function AddButton(parent, text, callback)
local btn = AceGUI:Create("Button")
btn:SetText(text)
btn:SetWidth(125)
btn:SetCallback("OnClick", callback)
parent:AddChild(btn)
return btn
end
-- Persistent widget references for live updates
local widgets = {}
local function BuildWindow()
local frame = AceGUI:Create("Frame")
frame:SetTitle("Overshields Reforged — Debug")
frame:SetStatusText("Discord: KTYA8uDeYv")
frame:SetWidth(300)
frame:SetHeight(775)
frame:SetLayout("Fill")
frame:SetCallback("OnClose", function()
Debug:Close()
end)
local scroll = AceGUI:Create("ScrollFrame")
scroll:SetLayout("Flow")
scroll:SetFullWidth(true)
scroll:SetFullHeight(true)
frame:AddChild(scroll)
-- Pipeline section
AddSectionHeader(scroll, "Pipeline")
widgets.hookFires = AddRow(scroll, "Hook Fires", "CompactUnitFrame_UpdateHealPrediction invocations received by the addon.")
widgets.queueAttempts = AddRow(scroll, "Queue Attempts", "Total calls to QueueCompactUnitFrameUpdate (includes all outcomes).")
widgets.queueAdds = AddRow(scroll, "Queue Adds", "Frames successfully added to the batch queue for processing.")
widgets.queueSkipsDuplicate = AddRow(scroll, "Queue Skips (Duplicate)", "Skipped because the frame was already in the queue this cycle.")
widgets.queueSkipsDisabled = AddRow(scroll, "Queue Skips (Disabled)", "Skipped because the frame's unit context (party/raid/pet) was disabled.")
widgets.batchCycles = AddRow(scroll, "Batch Cycles", "Number of OnUpdate batch processing cycles that ran.")
widgets.avgBatchSize = AddRow(scroll, "Avg Batch Size", "Average number of frames processed per batch cycle.")
widgets.peakBatchSize = AddRow(scroll, "Peak Batch Size", "Largest single batch of frames processed in one OnUpdate cycle.")
widgets.frameUpdates = AddRow(scroll, "Frame Updates", "HandleCompactUnitFrameUpdate calls that ran to completion (past all guards).")
widgets.earlyExits = AddRow(scroll, "Early Exits", "Updates aborted early (unit missing, glow forbidden, or no healthBar).")
widgets.retryAttempts = AddRow(scroll, "Retry Attempts", "Frames re-queued because healthBar was not yet available.")
widgets.retrySuccesses = AddRow(scroll, "Retry Successes", "Previously deferred frames that succeeded on a subsequent cycle.")
widgets.retryDrops = AddRow(scroll, "Retry Drops", "Frames dropped after exceeding the maximum retry count.")
-- Caches section
AddSectionHeader(scroll, "Caches")
widgets.absorbCacheSize = AddRow(scroll, "Absorb Bar Cache", "Active entries in the custom absorb StatusBar cache.")
widgets.overlayCacheSize = AddRow(scroll, "Overlay Bar Cache", "Active entries in the custom overlay StatusBar cache.")
widgets.styleCacheSize = AddRow(scroll, "Style Cache", "Active entries in the weak-keyed appearance style cache.")
widgets.barCreates = AddRow(scroll, "Bar Creates", "GetOrCreate cache misses — a new StatusBar was created.")
widgets.barReuses = AddRow(scroll, "Bar Reuses", "GetOrCreate cache hits — existing StatusBar returned.")
-- Styling section
AddSectionHeader(scroll, "Styling")
widgets.colorRatio = AddRow(scroll, "Color Applied / Skipped", "SetStatusBarColor calls (applied) vs. cache-hit skips. Lower ratio = better caching.")
widgets.textureRatio = AddRow(scroll, "Texture Applied / Skipped", "SetStatusBarTexture calls (applied) vs. cache-hit skips.")
widgets.blendRatio = AddRow(scroll, "Blend Applied / Skipped", "SetBlendMode calls (applied) vs. cache-hit skips.")
widgets.contextDisabled = AddRow(scroll, "Context Disabled", "ApplyAppearanceToFrame early returns because IsFrameContextEnabled was false.")
widgets.anchorModeChanges = AddRow(scroll, "Anchor Mode Changes", "Bar _anchorMode transitions (default/health_left/health_right/frame_left/frame_right).")
widgets.nativeBarsSuppressed = AddRow(scroll, "Native Bars Suppressed", "SuppressNativeAbsorbVisuals calls that hid Blizzard's native absorb bars.")
widgets.fullRefreshes = AddRow(scroll, "Full Refreshes", "UpdateAllFrameAppearances invocations (triggered by settings changes).")
widgets.lastRefreshTime = AddRow(scroll, "Last Refresh", "Time since the last full appearance refresh.")
widgets.poolPath = AddRow(scroll, "Pool Iteration Path", "Which API path UpdateFramePool used last: pools, frameReservations, or legacy.")
-- Active Frames section
AddSectionHeader(scroll, "Active Frames")
widgets.framesShown = AddRow(scroll, "Shown / Hidden", "Frames processed as shown (styled) vs. hidden (bars hidden) by ProcessFrame.")
widgets.partyFrames = AddRow(scroll, "Party", "Frames in absorb cache with a party unit token.")
widgets.raidFrames = AddRow(scroll, "Raid", "Frames in absorb cache with a raid unit token.")
widgets.petFrames = AddRow(scroll, "Pet", "Frames in absorb cache with a pet unit token.")
-- Hibernate section
AddSectionHeader(scroll, "Hibernate")
widgets.hibernateState = AddRow(scroll, "State", "Current effective hibernate state and override mode.")
widgets.hibernateEvals = AddRow(scroll, "Evaluations", "Total calls to EvaluateHibernation (event-driven context checks).")
widgets.hibernateTransitions = AddRow(scroll, "Transitions", "State changes between hibernating and active.")
-- Controls section
AddSectionHeader(scroll, "Controls")
local controlGroup = AceGUI:Create("SimpleGroup")
controlGroup:SetLayout("Flow")
controlGroup:SetFullWidth(true)
scroll:AddChild(controlGroup)
AddButton(controlGroup, "Clear All", function()
ResetTable(windowCounters, counters)
for k, v in ns.pairs(counters) do
if type(v) == "number" then
counters[k] = 0
elseif type(v) == "string" then
counters[k] = ""
end
end
counters.poolPath = "none"
end)
AddButton(controlGroup, "Clear Current", function()
ResetTable(windowCounters, counters)
end)
return frame
end
local function RefreshDisplay()
if not debugFrame then return end
local s = counters
local w = windowCounters
-- Pipeline
widgets.hookFires:SetText(FormatDual(s.hookFires, w.hookFires))
widgets.queueAttempts:SetText(FormatDual(s.queueAttempts, w.queueAttempts))
widgets.queueAdds:SetText(FormatDual(s.queueAdds, w.queueAdds))
widgets.queueSkipsDuplicate:SetText(FormatDual(s.queueSkipsDuplicate, w.queueSkipsDuplicate))
widgets.queueSkipsDisabled:SetText(FormatDual(s.queueSkipsDisabled, w.queueSkipsDisabled))
widgets.batchCycles:SetText(FormatDual(s.batchCycles, w.batchCycles))
local avgSession = s.batchCycles > 0 and string.format("%.1f", s.batchFramesTotal / s.batchCycles) or "0"
local avgWindow = w.batchCycles > 0 and string.format("%.1f", w.batchFramesTotal / w.batchCycles) or "0"
widgets.avgBatchSize:SetText(avgSession .. " (+" .. avgWindow .. ")")
widgets.peakBatchSize:SetText(FormatDual(s.peakBatchSize, w.peakBatchSize))
widgets.frameUpdates:SetText(FormatDual(s.frameUpdates, w.frameUpdates))
widgets.earlyExits:SetText(FormatDual(s.earlyExits, w.earlyExits))
widgets.retryAttempts:SetText(FormatDual(s.retryAttempts, w.retryAttempts))
widgets.retrySuccesses:SetText(FormatDual(s.retrySuccesses, w.retrySuccesses))
widgets.retryDrops:SetText(FormatDual(s.retryDrops, w.retryDrops))
-- Caches
widgets.absorbCacheSize:SetText(tostring(CountTable(ns.absorbCache)) .. " entries")
widgets.overlayCacheSize:SetText(tostring(CountTable(ns.overlayCache)) .. " entries")
-- styleCache is local to AppearanceManager; expose count via ns
local styleCount = ns.GetStyleCacheSize and ns.GetStyleCacheSize() or "?"
widgets.styleCacheSize:SetText(tostring(styleCount) .. " entries")
widgets.barCreates:SetText(FormatDual(s.barCreates, w.barCreates))
widgets.barReuses:SetText(FormatDual(s.barReuses, w.barReuses))
-- Styling
widgets.colorRatio:SetText(FormatRatio(s.colorApplied, s.colorSkipped) .. " (+" .. FormatRatio(w.colorApplied, w.colorSkipped) .. ")")
widgets.textureRatio:SetText(FormatRatio(s.textureApplied, s.textureSkipped) .. " (+" .. FormatRatio(w.textureApplied, w.textureSkipped) .. ")")
widgets.blendRatio:SetText(FormatRatio(s.blendApplied, s.blendSkipped) .. " (+" .. FormatRatio(w.blendApplied, w.blendSkipped) .. ")")
widgets.contextDisabled:SetText(FormatDual(s.contextDisabled, w.contextDisabled))
widgets.anchorModeChanges:SetText(FormatDual(s.anchorModeChanges, w.anchorModeChanges))
widgets.nativeBarsSuppressed:SetText(FormatDual(s.nativeBarsSuppressed, w.nativeBarsSuppressed))
widgets.fullRefreshes:SetText(FormatDual(s.fullRefreshes, w.fullRefreshes))
widgets.lastRefreshTime:SetText(FormatTimestamp(s.lastRefreshTime))
widgets.poolPath:SetText(tostring(s.poolPath))
-- Active Frames
widgets.framesShown:SetText(FormatDual(s.framesShown, w.framesShown) .. " / " .. FormatDual(s.framesHidden, w.framesHidden))
local party, raid, pet = CountFramesByContext(ns.absorbCache)
widgets.partyFrames:SetText(tostring(party))
widgets.raidFrames:SetText(tostring(raid))
widgets.petFrames:SetText(tostring(pet))
-- Hibernate
local hState = ns.hibernating and "|cffff8800On|r" or "|cff00ff00Off|r"
local hMode
if ns.hibernateOverride == true then
hMode = "m: off"
elseif ns.hibernateOverride == false then
hMode = "m: on"
else
hMode = "auto"
end
widgets.hibernateState:SetText(hState .. " (" .. hMode .. ")")
widgets.hibernateEvals:SetText(FormatDual(s.hibernateEvals, w.hibernateEvals))
widgets.hibernateTransitions:SetText(FormatDual(s.hibernateTransitions, w.hibernateTransitions))
end
-------------------------------------------------------------------------------
-- Toggle / Open / Close
-------------------------------------------------------------------------------
function Debug:Open()
if debugFrame then return end
ResetTable(windowCounters, counters)
debugFrame = BuildWindow()
RefreshDisplay()
refreshTicker = C_Timer.NewTicker(0.5, RefreshDisplay)
end
function Debug:Close()
if refreshTicker then
refreshTicker:Cancel()
refreshTicker = nil
end
if debugFrame then
debugFrame:Release()
debugFrame = nil
end
ns.wipe(widgets)
end
function Debug:Toggle()
if debugFrame then
self:Close()
else
self:Open()
end
end