~eliasnaur/gio

3 3

unbounded slice growth in Router.Event()?

Details
Message ID
<CAE_L6Q4fFqtvmXkoMPXvRBL=Bd7=YBDiVwqZjQTM9D7A5N-vmA@mail.gmail.com>
DKIM signature
pass
Download raw message
I'm investigating unexpected memory growth and heap profiling points
to gioui.org@v0.6.0/io/input/router.go:307 holding onto scratchFilters
in Router.key.processedFilter. In my case, this appears to be caused
by checking *widget.Clickable.Clicked() on each FrameEvent.

A minimal-ish reproducer:
https://gist.github.com/j2webs/1b95a6204a6c30c8555b095e1768de30

And a heap profile for convenience:
https://drive.google.com/file/d/1RdZUh1fGU8dyoqk6TIfq3_FwvUx29Z8m

Running the reproducer with a larger number of buttons, e.g. 15, will
accelerate the effect such that it shows up relatively quickly when
profiling.

A cursory dig in the surrounding code didn't turn up anything
managing/capping (or using?) Router.key.processedFilter, but I could
be missing something. Are we simply missing something in our use of
*widget.Clickable?

Thanks,
Joe Webster
Details
Message ID
<f527861c-864d-41d6-8fcf-5befff9a69aa@app.fastmail.com>
In-Reply-To
<CAE_L6Q4fFqtvmXkoMPXvRBL=Bd7=YBDiVwqZjQTM9D7A5N-vmA@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
I notice that yesterday, while woking on my year-long PR [0]. Seems that exists two 
`scratchFilters`, one of them is on the "root" and another inside "Key" sub-struct.

The "key sub-struct" only appends, but never resets or it's used. I silent remove it [1],
I'm not aware of any side-effect. Try to remove this append line and check if stuff
still running.


[0] https://github.com/gioui/gio/pull/117/commits/e6f6b3d76e61f314ece1755dd3ce6785dc9af9c1
[1] https://github.com/gioui/gio/pull/117/commits/e6f6b3d76e61f314ece1755dd3ce6785dc9af9c1#diff-c04c544d7677b4f40b53717995fb8f2e3d67212768e651e229ef2c020fc0d357L306-L308

-- 
  Lucas Rodrigues
  inkeliz@inkeliz.com

On Tue, Jun 4, 2024, at 7:55 PM, Joe Webster wrote:
> I'm investigating unexpected memory growth and heap profiling points
> to gioui.org@v0.6.0/io/input/router.go:307 holding onto scratchFilters
> in Router.key.processedFilter. In my case, this appears to be caused
> by checking *widget.Clickable.Clicked() on each FrameEvent.
>
> A minimal-ish reproducer:
> https://gist.github.com/j2webs/1b95a6204a6c30c8555b095e1768de30
>
> And a heap profile for convenience:
> https://drive.google.com/file/d/1RdZUh1fGU8dyoqk6TIfq3_FwvUx29Z8m
>
> Running the reproducer with a larger number of buttons, e.g. 15, will
> accelerate the effect such that it shows up relatively quickly when
> profiling.
>
> A cursory dig in the surrounding code didn't turn up anything
> managing/capping (or using?) Router.key.processedFilter, but I could
> be missing something. Are we simply missing something in our use of
> *widget.Clickable?
>
> Thanks,
> Joe Webster
Details
Message ID
<CAMAFT9V4=BZyrXh948rV+WiAumE1i843UpoLwTC2mVM=0F39bg@mail.gmail.com>
In-Reply-To
<CAE_L6Q4fFqtvmXkoMPXvRBL=Bd7=YBDiVwqZjQTM9D7A5N-vmA@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
Hi Joe,

Thanks for noticing and reporting this issue, which should be fixed by

gioui.org/commit/56177c55cfbb4e07008f7646f0eb8d9912e95423

Elias
Details
Message ID
<CAE_L6Q7M8U1ey6otHHDeqAEZt7Be+0h7ROnNrm1UHefwk4t8cg@mail.gmail.com>
In-Reply-To
<CAMAFT9V4=BZyrXh948rV+WiAumE1i843UpoLwTC2mVM=0F39bg@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
Hi Elias,

Thank you! I was preparing to inquire about the appropriate course of
action (removal or, perhaps, mirroring handler.processedFilter's use
in Router.execute()) -- I guess you've answered the question!

Best,
Joe

On Fri, Jun 7, 2024 at 4:34 AM Elias Naur <mail@eliasnaur.com> wrote:
>
> Hi Joe,
>
> Thanks for noticing and reporting this issue, which should be fixed by
>
> gioui.org/commit/56177c55cfbb4e07008f7646f0eb8d9912e95423
>
> Elias
Reply to thread Export thread (mbox)