BaseAdView.pause()/resume() for app performance

49 views
Skip to first unread message

Hermawan Winata

unread,
Sep 13, 2024, 2:43:40 AMSep 13
to Google Mobile Ads SDK Developers
Hi team,

I'm getting mixed signals whether `BaseAdView.pause()` and `BaseAdView.resume()` is recommended. Eric mentioned here that it's used to pause and resume the internal WebView. But recently they should be avoided?

From this example, `pause` and `resume` are called. But this example does not. Could you clarify how important/dangerous is calling `BaseAdView.pause()` and `BaseAdView.resume()`?

Mobile Ads SDK Forum Advisor

unread,
Sep 13, 2024, 8:55:26 AMSep 13
to google-adm...@googlegroups.com

Hi,

Thank you for contacting the Mobile Ads SDK Support team.

BaseAdView.pause() Pauses any extra processing associated with this ad view. This method should be called in the parent Activity's Activity.onPause() method. The method calls when the user no longer actively interacts with the activity, but it is still visible on screen.  

BaseAdView.resume() Resumes an ad view after a previous call to pause(). This method should be called in the parent Activity's Activity.onResume() method. 

For more information kindly refer to BaseAdView and The activity lifecycle. Kindly check our release notes for any updates.

I hope this helps! Let me know if you have any other questions.

This message is in relation to case "ref:!00D1U01174p.!5004Q02vG6f8:ref" (ADR-00268057)

Thanks,
 
Google Logo Mobile Ads SDK Team


Hermawan Winata

unread,
Sep 20, 2024, 5:17:03 AMSep 20
to Google Mobile Ads SDK Developers
Hi, 

Thank you for your response. However it does not provide any reasons for the statement given here (quoted below) by William Pescherine.

> We would strongly suggest not using the adView.pause() as this has been known to cause issues. This can cause ANR or app crashes. You are able to use them but we just recommend against using them.

Can you re-confirm that adView.pause() will not cause ANR and crashes?

Mobile Ads SDK Forum Advisor

unread,
Sep 20, 2024, 12:12:36 PMSep 20
to shin...@gmail.com, google-adm...@googlegroups.com

Hi,

I would recommend to follow Eric's comment mentioned here.

"AdView.pause() and AdView.resume() just forward the calls to webView.onPause() and webView.onResume() right now. They don't stop loading/refreshes of ads yet, but we've thought about using it at some point in the future as a better (or additional) signal to stop refreshing ads than the current check if the AdView is visible.

The onPause and onResume calls will also be forwarded to any mediation networks or custom events using the new mediation/custom event APIs.
destroy() forwards to webView.destroy() and also does some other internal cleanup. We don't have 1.x Android webview crashes anymore but we still recommend calling this."


Thanks

Reply all
Reply to author
Forward
0 new messages