mobile-sdk-android icon indicating copy to clipboard operation
mobile-sdk-android copied to clipboard

TreeWalker eats CPU

Open AAverin opened this issue 4 years ago • 5 comments

I have been looking into some lags in the app and when the app is completely idle and there are no ads visible on the screen at the moment, CPU profiling shows this picture.

image

What is TreeWalker and why does it run every frame making expensive calls to get display info and real size?

AAverin avatar Sep 04 '20 15:09 AAverin

Hi @AAverin

TreeWalker is part of OpenMeasurment SDK integrated with Xandr SDK. This is for calculating Viewability of the Ad being rendered and gets reported in our Viewability metrics. It runs every 200ms to detect if the Ad is on screen or not and also the actual co-ordinates fo the ad on screen.

Kowshickkarthick avatar Sep 10 '20 21:09 Kowshickkarthick

@Kowshickkarthick I understand that it's probably a part of iAB implementation, but I didn't find a way to reach to them directly. I am also trying to push this bug through other channels and also have reported it to Google Ads team. I get the need to detect ads viewability, but there should be a way to avoid calling getRealSize that twice every 200ms. The value for getRealSize would only change with device rotation. Sure there should be a way to pre-calculate or cache that value.

At the moment this walking is responsible for 60% of CPU load in our app. This basically means that if we want to make sure our app is performant (as native app should be), we should squeeze all our business logic and view calculations into 40% that are left. So out of 16ms per frame available for 60fps draws, we have just 7 or even less if we want to push to 90fps.

AAverin avatar Sep 11 '20 08:09 AAverin

Escalated to IAB via their slack channel. They are reviewing this with their engineers.

srijithnair avatar Dec 15 '20 15:12 srijithnair

Closing this issue because it has been open for a long time and there are no recent interactions on this. If this is still relevant in the latest SDK version feel free to reach out through the support team

avohraa avatar Apr 19 '22 13:04 avohraa

@avohraa shouldn't this stay open until any feedback from IAB team comes back? Was there any feedback? Is there a related issue made for Google?

AAverin avatar Apr 19 '22 17:04 AAverin