performance-samples icon indicating copy to clipboard operation
performance-samples copied to clipboard

JankStatsAggregator.issueJankReport concurrency issues

Open tommybart opened this issue 1 year ago • 1 comments

The example JankStatsAggregator class can produce ConcurrentModificationException for listeners that perform some additional operations on it. Presumably because of how FrameData objects are internally mutated.

It appears that JankStatsAggregator.issueJankReport attempts to account for that with copies, but it may not be fully thread safe.

For example:

private val reportListener = JankStatsAggregator.OnJankReportListener { _, _, jankFrameData -> 
    jankFrameData.filter(...).map { frame ->
        // Do something with FrameData and/or StateInfo
    }
}

This usage results in rare concurrency exceptions. I'm not sure if it is a misusage on my end, but as a user I would expect the listener to be thread safe.

tommybart avatar Jan 08 '25 19:01 tommybart

Thank you for reporting this issue. It doesn't look like an issue with this sample but the library itself. Please add the details requested to an issue on the product issue tracker.

keyboardsurfer avatar Jan 14 '25 08:01 keyboardsurfer