Skip to content

Conversation

ggcrunchy
Copy link
Contributor

As mentioned in the closing comment of #660, I realized the case with static IDs was pretty hopeless. Thankfully, it was actually rather easy at this point to move them into the ProfilingState, which was on hand when they were needed. Previous design was a bit of inertia from the former stack trace-stifling version. 😄

I reproduced the issue on Mac, mentioned in #help-and-support on Discord, where launching from, say, the file dialog, would lead to a crash. With this it goes away.

ggcrunchy and others added 26 commits February 7, 2019 17:09
…nd buffer and assignment logic

Next up, prepare details from graphics.defineEffect()
…from Program

Slight redesign of TimeTransform with caching (to synchronize multiple invocations with a frame) and slightly less heavyweight call site
Err, was calling Modulo for sine method, heh

That said, time transform seems to work in basic test
Fixed error detection for positive number time transform inputs

Relaxed amplitude positivity requirement
Maintenance Revert Test
My mistake adding back changes made
…, but aren't used in production)

GetOrCreate() removed; the ones not used by event listeners are Create()'d up front

Slight change of PROFILING_BEGIN() macro for new usage

Simulator run variable is gone now
…listener, rather than when event name first appeared globally

Removed ShortName (since it also blew up the size of some structures) and enforcing that profiling-related string lifetimes are static or held in Lua

Replaced with Payload that can take a string or a pointer (table or function)

Also has an option for owned strings, but probably iffy (or could be something else instead)

Due to that, able to avoid some allocations in getTimings()

Also added other possiblities there when time is false (as with sublists), using a @ at start to indicate keyword
@ggcrunchy
Copy link
Contributor Author

I let leak slip into the PR commit (details in 894b3ad's comments). That should be fixed now; I let this test churn through a few million objects and memory leveled off early and held steady:

local ii=0
local jj=0
local kk=0

Runtime:addEventListener("enterFrame", function()
  ii=ii+1
  for _ = 1, 50 do
    local r = display.newRect(1, 2, 3, 4)
    r:addEventListener("buffalo", function()
      jj=jj+1
    end)
    function r.cow ()
      kk=kk-2
    end
    r:addEventListener("cow")
    r:dispatchEvent{ name = "buffalo" }
    r:dispatchEvent{ name = "cow" }
    r:removeSelf()
  end
  if ii == 500 then
    print("!!", jj, kk)
    ii=0
  end
end)

I did a bit of reorganization while I was at it. I'm double-checking with those folks that I know did anything with the results so far, but made a very slight change to the output of display.getTiming(): when time is false, if the what string starts with @ it's a "keyword" (so far either "@tableListeners" or "@functionListeners"). My "basic example" in #551 then has the following change:

local function PrintList (name, indent)
  local timings = table.remove(tstack) or {}
  local n = display.getTimings(timings, name)

  indent = indent or " "

  print(indent .. "> " .. name)

  for i = 1, n, 2 do
    local what, time = timings[i], timings[i + 1]

    if time then
      print(indent .. " ", what, time / 1e3)
    elseif what:starts("@") then -- keyword?
      if what:ends("Listeners") then
        print(indent .. "  *" .. what:sub(2))
      end
    else -- sublist?
      PrintList(what, indent .. "  ")
    end
  end

  tstack[#tstack + 1] = timings
end

…nes like update and render, by the looks of it); just using raw ones and a Type member now in payloads
@ggcrunchy
Copy link
Contributor Author

849f318's comment should read "assumption of aligned strings". Anyhow, with that revision it seems okay on Mac, and I'll put it through its Android paces shortly.

@Shchvova Shchvova merged commit c151ca7 into coronalabs:master Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants