awls99 / Random-Hearthstone-Toy-Continued

A continuation of Hemco's random Hearth toy
MIT License
0 stars 1 forks source link

Make local leaked globals, fix XP bar flicker issue #11

Closed teelolws closed 1 year ago

teelolws commented 1 year ago

So I've found this addon is causing the XP and Reputation bars to flicker, while RHT is trying to initialize. During setup, RHT will clear existing toybox filters, look for hearthstones, then reset the existing toybox filters.

Every time it changes the toybox filters, the XP and Reputation bars flicker. I don't know why, I certainly don't see any connection. Probably a bug on Blizzards end.

The problem is, if any of these situations happens:

  1. The player has no Hearthstones, or
  2. The local game hasn't cached data about hearthstone toys yet, or
  3. The player has Expansion/Source filters setup that filter out all their hearthstones,

then RHT keeps trying over and over every second, checking the toybox again and again. This causes the XP and Rep bars to keep flickering every second until the toybox finally works, which probably won't happen until the player opens their toybox and resets all the filters.

The change I've made here is to not reset back to the player's original filters if a hearthstone is not found.

teelolws commented 1 year ago

Actually theres more to this that I can't find. This change stops the issue happening, but doesn't seem to be the true cause.

I setup tickers that turn the filters on and off every second, but the flickering isn't happening.

teelolws commented 1 year ago

Okay I got it. Its to do with watching a frame's OnUpdate. The flicker doesn't happen if I switch that whole RHT.to to a C_Timer.NewTicker.

awls99 commented 1 year ago

this ticker change looks like a great improvement thanks. Later tonight I'll test this and merge :D

teelolws commented 1 year ago

Quick script to demo the problem. Track a reputation then: /run local f,a=CreateFrame("Frame"),0 f:SetScript("OnUpdate", function(_,e) if a>-1 then a=a-e return end a=0 C_ToyBox.SetCollectedShown(not C_ToyBox.GetCollectedShown()) end)

If you swap that timer based on OnUpdate out for a C_Timer, no flicker.