Add IconOverlay2 to Item Button#701
Add IconOverlay2 to Item Button#701shawngmc wants to merge 1 commit intoAdiAddons:masterfrom shawngmc:master
Conversation
Add IconOverlay2 support to ItemButton in a future-proof way, and add the call to an addon.isRetail guard block.
|
Note: I tested this with a piece of Azerite gear. |
|
Technically you add support for both overlays ( I know that I suggested this change, but I'm wondering if we could avoid making that many calls to if self.hasItem then
local _, _, quality = GetContainerItemInfo(self.bag, self.slot)
SetItemButtonOverlay(self, self.itemId or self.itemLink, quality)
else
SetItemButtonOverlay(self, 0)
end |
GetContainerItemInfo is already cached locally in the WoW client - this call is not networked unless there's a miss. I haven't had a chance to check the code on this yet (busy week at my day job!), but can someone please confirm this code does not break Classic and Wrath as well? Also, please be sure to test as many interactions as possible, i.e. sort your bags after messing them up, deposit and remove from the bank, open the bag in "Backback" sorted mode and try to break it, etc. This has to be done for all three versions of WoW on the market today. Thanks! |
|
(Note: I see that it's in an addon.isRetail block, but the code must be tested everywhere regardless please. Thank you!) |
Isn't it still faster/less overhead to cache the values and access them than querying the method every time?
Have to say that I do not see the relevance of testing this outside of Retail considering that it's not possible that this condition fails. The code would never run - you would basically only test Having said that, I did notice some bug while testing it, but it isn't related. As a side note, I find the new behavior of marking swapped items as "Recent Items" not really convenient and especially annoying for testing. |
It may be, I have not tested nor benched this, but generally this call is on the order of microseconds. We'd be adding complexity around cache invalidation, and adding more memory pressure to the client should we build a cache for this. If this becomes an issue in the future, we can evaluate this, but I suspect it won't be.
Because the code is loaded in all environments, all environments must be tested and QA'd, regardless of well-known paths. This is to ensure regressions not only in our code, but in Blizzard's code, do not cause issues. Unfortunately, because Blizzard has decided to significantly alter the API in some instances between versions, one single regression could break this addon for thousands or tens of thousands of people, even when gated appropriately behind a flag. We recently witnessed this with Wrath when Blizzard changed the flags used to detect if a user is in Wrath -- this broke
Can you open a bug report for this, with your exact tests, a reproduction case, items used, etc?
Testing is a side-effect in this instance. Please feel free to issue a feature request on this, with a proposed design so we can evaluate it. Thanks! |
I'd argue that we do not really care about memory pressure in Lua. But I agree that it might get complicated for not much. This is likely not related, but I was thinking about this to avoid issues like the freeze that happens when you sort the bags, which doesn't happen on base UI. So there's likely some progress that can be made on the optimization.
I still can't believe that they've done this out of nowhere, and broke multiple add-ons, including Bartender, with a minor patch. But you make a point. Either way, I already tested this on Wrath and Vanilla. And I just completed testing it on Retail.
I mean, I simply expect it to behave like when |
Please open a bug on this if you feel this is a bug -- let's not pollute the PR discussion please. @shawngmc Are you ready to merge these changes? edit: Also open a bug on the bag freeze, please. |
This is probably worth looking into. In any case, it doesn't make sense to add the second one without adding the first as well.
Additional function calls should be avoided whenever possible for optimal performance in Lua. They're much more resource expensive than the added conditional checking—at the expense of extra code verbosity, of course. |
While true, I think this sort of optimization doesn't behoove a bag addon, whose calls are not continuous, with the CPU's of 2022. I want to be careful about pre-optimizing something that hasn't been shown to be a problem arbitrarily for the sake of being CPU time optimal, at the cost of readability. There are other parts of the code that are very much in need of time optimization, and I have a few ideas on how to tackle them. However, it will require a significant amount of code rewrite, and should be done at a later date. |
Add IconOverlay2 support to ItemButton in a future-proof way, and add the call to an addon.isRetail guard block.
Replacement for #445. (My original fork has been deleted and there are a number of changes that would need brought up to speed.)