Skip to content

Commit

Permalink
Fix massive memory usage
Browse files Browse the repository at this point in the history
* Don't add various functions to the loginQueue if they are already in
there
* Don't add ScanForLoads from the loginQueue, it should be called
anyway.
* Make sure that we run the event handlers for various events, as some
of them can happen after the longQueue is empty
* Use a while loop to iterate, because we are potentially adding stuff
while looping and I don't know whether that's supported.

Github-Issue: #1016
Ticket-Nr: 1281, 1282
  • Loading branch information
InfusOnWoW committed Dec 12, 2018
1 parent 61dc507 commit 2cd3998
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions WeakAuras/WeakAuras.lua
Expand Up @@ -1356,13 +1356,17 @@ local loginThread = coroutine.create(function()
WeakAuras.RegisterLoadEvents();
WeakAuras.Resume();
coroutine.yield();
for _, callback in ipairs(loginQueue) do
if type(callback) == 'table' then
callback[1](unpack(callback[2]))

local nextCallback = loginQueue[1];
while nextCallback do
tremove(loginQueue, 1);
if type(nextCallback) == 'table' then
nextCallback[1](unpack(nextCallback[2]))
else
callback()
nextCallback()
end
coroutine.yield();
nextCallback = loginQueue[1];
end
end)

Expand Down Expand Up @@ -1421,8 +1425,8 @@ loadedFrame:SetScript("OnEvent", function(self, event, addon)
elseif(event == "LOADING_SCREEN_ENABLED") then
in_loading_screen = true;
elseif(event == "LOADING_SCREEN_DISABLED") then
else
in_loading_screen = false;
else
local callback
if(event == "PLAYER_ENTERING_WORLD") then
-- Schedule events that need to be handled some time after login
Expand All @@ -1449,7 +1453,11 @@ loadedFrame:SetScript("OnEvent", function(self, event, addon)
end
end
end
loginQueue[#loginQueue + 1] = callback
if WeakAuras.IsLoginFinished() then
callback()
else
loginQueue[#loginQueue + 1] = callback
end
end
end);

Expand Down Expand Up @@ -1591,11 +1599,17 @@ function WeakAuras.CreateEncounterTable(encounter_id)
return WeakAuras.CurrentEncounter
end

local encounterScriptsDeferred = {}
function WeakAuras.LoadEncounterInitScripts(id)
if not WeakAuras.IsLoginFinished() then
if encounterScriptsDeferred[id] then
return
end
loginQueue[#loginQueue + 1] = {WeakAuras.LoadEncounterInitScripts, {id}}
encounterScriptsDeferred[id] = true
return
end
encounterScriptsDeferred = nil
if (WeakAuras.currentInstanceType ~= "raid") then
return
end
Expand Down Expand Up @@ -1636,7 +1650,6 @@ local toLoad = {}
local toUnload = {};
function WeakAuras.ScanForLoads(self, event, arg1, ...)
if not WeakAuras.IsLoginFinished() then
loginQueue[#loginQueue + 1] = WeakAuras.ScanForLoads
return
end
if (WeakAuras.IsOptionsProcessingPaused()) then
Expand Down Expand Up @@ -4156,6 +4169,7 @@ end
do
local customTextUpdateFrame;
local updateRegions = {};
local initRequested = false

local function DoCustomTextUpdates()
WeakAuras.StartProfileSystem("custom text - every frame update");
Expand All @@ -4173,9 +4187,14 @@ do
WeakAuras.StopProfileSystem("custom text - every frame update");
end


function WeakAuras.InitCustomTextUpdates()
if not WeakAuras.IsLoginFinished() then
if initRequested then
return
end
loginQueue[#loginQueue] = WeakAuras.InitCustomTextUpdates
initRequested = true
return
end
if not(customTextUpdateFrame) then
Expand Down

0 comments on commit 2cd3998

Please sign in to comment.