{"id":58629,"date":"2023-10-08T12:38:59","date_gmt":"2023-10-08T07:08:59","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=58629"},"modified":"2023-10-18T12:52:33","modified_gmt":"2023-10-18T07:22:33","slug":"anr-for-tv","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/anr-for-tv\/","title":{"rendered":"ANR for TV"},"content":{"rendered":"<h2><b>Description<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">When the UI thread of an Android app is blocked for too long, an &#8220;Application Not Responding&#8221; (ANR) error is triggered. If the app is in the foreground, the system displays a dialog to the user, as shown in the figure below.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">ANRs are a problem because the app&#8217;s main thread, which is responsible for updating the UI, can&#8217;t process user input events or draw, causing frustration to the user.<\/span><\/p>\n<h2><b>Reasons for ANR<\/b><\/h2>\n<ol>\n<li style=\"font-weight: 400;\"><b>Main thread Lock <\/b><span style=\"font-weight: 400;\">: If the main thread is locked for long.\u00a0 <\/span><\/li>\n<li style=\"font-weight: 400;\"><b>High CPU Utilization on Main thread : <\/b>\u00a0Big operation on Main thread.<\/li>\n<li style=\"font-weight: 400;\"><b>RAM<\/b>: Low RAM causes the TV to hang and produce ANR<\/li>\n<\/ol>\n<h2 id=\"android-vitals\" role=\"presentation\" data-text=\"Android vitals\"><span class=\"devsite-heading\" role=\"heading\">Android vitals<\/span><button class=\"devsite-heading-link button-flat material-icons\" type=\"button\" aria-label=\"Copy link to this section: Android vitals\" data-title=\"Copy link to this section: Android vitals\" data-id=\"android-vitals\"><\/button><\/h2>\n<p>Android vitals can help you monitor and improve your app&#8217;s ANR rate. Android vitals measures several ANR rates:<\/p>\n<ul>\n<li><strong>ANR rate:<\/strong>\u00a0The percentage of your daily active users who experienced any type of ANR.<\/li>\n<li><strong>User-perceived ANR rate:<\/strong>\u00a0The percentage of your daily active users who experienced at least one\u00a0<em>user-perceived ANR<\/em>. Currently, only ANRs of this type <code>Input dispatching timed out<\/code>\u00a0are considered user-perceived.<\/li>\n<li><strong>Multiple ANR rate:<\/strong>\u00a0The percentage of your daily active users who experienced at least two ANRs.<\/li>\n<\/ul>\n<p>A\u00a0<em>daily active user<\/em> is a unique user who uses your app daily on a single device, potentially over multiple sessions. If a user uses your app on more than one device in a single day, each device will contribute to the number of active users for that day. If multiple users use the same device daily, this is counted as one active user.<\/p>\n<p>User-perceived ANR rate is a\u00a0<em>core vital<\/em>\u00a0meaning that it affects the discoverability of your app on Google Play. It is important because the ANRs it counts always occur when the user is engaged with the app, causing the most disruption.<\/p>\n<p>Play has defined two\u00a0<strong>bad behavior thresholds<\/strong>\u00a0on this metric:<\/p>\n<ul>\n<li><strong>Overall bad behavior threshold:<\/strong>\u00a0At least 0.47% of daily active users experience a user-perceived ANR, across all device models.<\/li>\n<li><strong>Per-device bad behavior threshold:<\/strong>\u00a0At least 8% of daily users experience a user-perceived ANR,\u00a0<strong>for a single-device model<\/strong>.<\/li>\n<\/ul>\n<p>If your app exceeds the overall bad behavior threshold, it will likely be less discoverable on all devices. If your app exceeds the per-device bad behavior threshold on some devices, it is likely to be less discoverable on those devices, and a warning may be shown on your store listing.<\/p>\n<h2 id=\"diagnose-anrs\" role=\"presentation\" data-text=\"Diagnose ANRs\"><span class=\"devsite-heading\" role=\"heading\">Diagnose ANRs<\/span><button class=\"devsite-heading-link button-flat material-icons\" type=\"button\" aria-label=\"Copy link to this section: Diagnose ANRs\" data-title=\"Copy link to this section: Diagnose ANRs\" data-id=\"diagnose-anrs\"><\/button><\/h2>\n<p>There are some common patterns to look for when diagnosing ANRs:<\/p>\n<ul>\n<li>The app is doing slow operations involving I\/O on the main thread.<\/li>\n<li>The app is doing a long calculation on the main thread.<\/li>\n<li>The main thread is doing a synchronous binder call to another process, and that other process is taking a long time to return.<\/li>\n<li>The main thread is blocked, waiting for a synchronized block for a long operation on another thread.<\/li>\n<li>The main thread is in a deadlock with another thread, either in your process or via a binder call. The main thread is not just waiting for a long operation to finish, but is in a deadlock situation.<\/li>\n<\/ul>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>Description When the UI thread of an Android app is blocked for too long, an &#8220;Application Not Responding&#8221; (ANR) error is triggered. If the app is in the foreground, the system displays a dialog to the user, as shown in the figure below. ANRs are a problem because the app&#8217;s main thread, which is responsible [&hellip;]<\/p>\n","protected":false},"author":1504,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":28},"categories":[518,4831,1817,1772,1994],"tags":[4845,5461,5538,5539,5537,3476],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/58629"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1504"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=58629"}],"version-history":[{"count":3,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/58629\/revisions"}],"predecessor-version":[{"id":59248,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/58629\/revisions\/59248"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=58629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=58629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=58629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}