Bagnon

Bagnon

122M Downloads

"script ran too long" + generic solution

rowaasr13 opened this issue ยท 4 comments

commented

I've recently outfitted one of my characters with 4 Hexweave Bags and started to routinely get errors like those listed below in combat. This one happens to point directly to the problem, but I had those mentioned in issue #319 and some profiling show they point to same problematic piece of code too: ItemSlot:Update() is called once for each item button, so when you have 30 * 14 + 16 = 136 items to update in full bags, even if every update takes just 2ms, you already go over 200ms, get the error and because of some peculiarity of Bagnon design that I didn't bother to research get bag interface locked.

Anyway, single item slot button is, obviously, well under that limit and I've recently found while working on my personal addon with same problem, that rescheduling function call to same frame gives it a separate counter and thus avoids problem with amount of calls that you can't control (i.e. you can't control how large player bags get). I've extracted the wrapping solution I use and packed it as LibStub-style library here: http://wow.curseforge.com/addons/libfiber/

Right now I run locally patched Bagnon where I added
local Fiber = LibStub('LibFiber-1.0')
among other definitions and
Fiber:WrapVoidMethod(ItemSlot, "Update")
right after definition of ItemSlot:Update method and I no longer get any errors.

Could you please review my lib and use it to protect execution from being terminated in combat if you like it?

Oh, I just checked ticket list more closely and it seems it will fix issue #317 too.

Message: Interface\AddOns\Bagnon\components\item.lua:71: script ran too long
Time: 02/10/15 08:13:38
Count: 1
Stack: Interface\AddOns\Bagnon\components\item.lua:71: in function ConstructNewItemSlot' Interface\AddOns\Bagnon\components\item.lua:27: in functionCreate'
Interface\AddOns\Bagnon\components\item.lua:22: in function New' Interface\AddOns\Bagnon\components\itemFrame.lua:253: in functionAddItemSlot'
Interface\AddOns\Bagnon\components\itemFrame.lua:324: in function ReloadAllItemSlots' Interface\AddOns\Bagnon\components\itemFrame.lua:193: in functionUpdateEverything'
Interface\AddOns\Bagnon\components\itemFrame.lua:469: in function SetFrameID' Interface\AddOns\Bagnon\components\itemFrame.lua:35: in functionNew'
Interface\AddOns\Bagnon\components\frame.lua:687: in function CreateItemFrame' Interface\AddOns\Bagnon\components\frame.lua:697: in functionPlaceItemFrame'
Interface\AddOns\Bagnon\components\frame.lua:399: in function Layout' Interface\AddOns\Bagnon\components\frame.lua:201: in functionUpdateLook'
...
[string "safecall Dispatcher[2]"]:4: in function <[string "safecall Dispatcher[2]"]:4>

[string "safecall Dispatcher[2]"]:13: in function ?' ...Ons\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.lua:92: in functionSendCallback'
Interface\AddOns\Bagnon\settings\frameSettings.lua:51: in function SendMessage' Interface\AddOns\Bagnon\settings\frameSettings.lua:69: in functionShow'
Interface\AddOns\Bagnon\main.lua:105: in function <Interface\AddOns\Bagnon\main.lua:102>
(tail call): ?
Interface\AddOns\Bagnon\main.lua:216: in function `ToggleAllBags'
[string "OPENALLBAGS"]:1: in function <[string "OPENALLBAGS"]:1>

Locals: self = {
SetHighlight = defined @interface\AddOns\Bagnon\components\item.lua:480
OnEnter = defined @interface\AddOns\Bagnon\components\item.lua:229
SetItem = defined @interface\AddOns\Bagnon\components\item.lua:291
Free = defined @interface\AddOns\Bagnon\components\item.lua:99
UpdateCooldown = defined @interface\AddOns\Bagnon\components\item.lua:416
Bind = defined @interface\AddOns\Bagnon\api\classes.lua:19
SetSlotColor = defined @interface\AddOns\Bagnon\components\item.lua:323
OnDragStart = defined @interface\AddOns\Bagnon\components\item.lua:189
SetLocked = defined @interface\AddOns\Bagnon\components\item.lua:339
GetBagColor = defined @interface\AddOns\Bagnon\components\item.lua:526
dummyBags =

{
}
UpdateTooltip = defined @interface\AddOns\Bagnon\components\item.lua:428
SetReadable = defined @interface\AddOns\Bagnon\components\item.lua:332
HandleEvent = defined @interface\AddOns\Bagnon\components\item.lua:165
Create = defined @interface\AddOns\Bagnon\components\item.lua:25
HideBorder = defined @interface\AddOns\Bagnon\components\item.lua:406
IsLocked = defined @interface\AddOns\Bagnon\components\item.lua:347
GetFrameID = defined @interface\AddOns\Bagnon\components\item.lua:584
GetEmptyItemIcon = defined @interface\AddOns\Bagnon\components\item.lua:306
IsQuestItem = defined @interface\AddOns\Bagnon\components\item.lua:537
RegisterMessage = defined @interface\AddOns\Bagnon\api\classes.lua:23
UnregisterMessage = defined @interface\AddOns\Bagnon\api\classes.lua:31
Update = defined @interface\AddOns\Bagnon\components\item.lua:261
GetSettings = defined @interface\AddOns\Bagnon\components\item.lua:530
UpdateSearch = defined @interface\AddOns\Bagnon\components\item.lua:456
ITEM_HIGHLIGHT_UPDATE = defined @interface\AddOns\Bagnon\components\item.lua:161
HighlightNewItems = defined @interface\AddOns\Bagnon\components\item.lua:502
EQUIPMENT_SETS_CHANGED = defined @interface\AddOns\Bagnon\components\item.lua:157
GetHighlightAlpha = defined

commented

Still relevant in 6.1.5 - well, ItemSlot:Update and calling it 136 times for my inventory didn't really changed much. Average time per call seems to be significantly lower now and errors happen noticeably less often, but I still get them in combat especially if I'm just zoned in and WoW slows down while background loading all the models and stuff. At least now close/open is no longer locked until reload, but since window layout update can be terminated in the middle you can get very funky screwed up half of inventory somewhere in bottom right corner until you close/open to force a complete update.

Message: Interface\AddOns\Bagnon\common\components\item.lua:425: script ran too long
Time: 03/22/15 09:03:43
Count: 1
Stack: Interface\AddOns\Bagnon\common\components\item.lua:425: in function IsQuestItem' Interface\AddOns\Bagnon\common\components\item.lua:305: in functionUpdateBorder'
Interface\AddOns\Bagnon\common\components\item.lua:218: in function Update' Interface\AddOns\Bagnon\common\components\item.lua:205: in functionSetTarget'
...erface\AddOns\Bagnon\common\components\itemFrame.lua:142: in function <...erface\AddOns\Bagnon\common\components\itemFrame.lua:108>

Locals: self = ContainerFrame4Item11 {
0 =
bag = 4
BattlepayItemTexture = {
}
Border = {
}
Flash = {
}
IconBorder = {
}
flashAnim = {
}
hasItem = "[Meatmonger's Gory Grips]"
icon = ContainerFrame4Item11IconTexture {
}
JunkIcon = {
}
QuestBorder = ContainerFrame4Item11IconQuestTexture {
}
count = 1
frame = BagnonFrameinventory {
}
NewItemTexture = {
}
readable = false
Count = ContainerFrame4Item11Count {
}
newitemglowAnim = {
}
flash = {
}
searchOverlay = ContainerFrame4Item11SearchOverlay {
}
Cooldown = ContainerFrame4Item11Cooldown {
}
SplitStack = defined @interface\FrameXML\ContainerFrame.lua:884
}
item = "[Meatmonger's Gory Grips]"
(_temporary) = nil
(_temporary) = nil
(_temporary) = nil
(_temporary) = nil
(_temporary) = nil
(_temporary) = "script ran too long"
ItemSearch =

{
Matches = defined @interface\AddOns\Bagnon\libs\LibItemSearch-1.2\LibItemSearch-1.2.lua:18
TooltipPhrase = defined @interface\AddOns\Bagnon\libs\LibItemSearch-1.2\LibItemSearch-1.2.lua:26
InSet = defined @interface\AddOns\Bagnon\libs\LibItemSearch-1.2\LibItemSearch-1.2.lua:30
Tooltip = defined @interface\AddOns\Bagnon\libs\LibItemSearch-1.2\LibItemSearch-1.2.lua:22
BelongsToSet = defined @interface\AddOns\Bagnon\libs\LibItemSearch-1.2\LibItemSearch-1.2.lua:250
Filters =
{
}
}
QuestSearch = "t:Quest|quest"

commented

Yes, but want to get overall new arquitecture working and well performant before adding this trick.

commented

@rowaasr13 , could you check the current code in the repo and tell me if this solves the problem for you? The performance is largely better for me now, and divided into multiple frames.

commented

For cached items, figuring out if an item is from a quest is 80% of the loading time -.-