# 在 Chrome 77 的 Android 版上，主题错误地停留在未读状态

**URL:** <https://meta.discourse.org/t/topics-incorrectly-stuck-in-unread-state-on-android-in-chrome-77/129907>\
**Category:** Bug\
**Created:** [2019 年10 月 1 日 02:37 UTC](https://meta.discourse.org/t/topics-incorrectly-stuck-in-unread-state-on-android-in-chrome-77/129907 "2019-10-01T02:37:03Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
发布日期： [2019 年10 月 1 日 02:37 UTC](https://meta.discourse.org/t/topics-incorrectly-stuck-in-unread-state-on-android-in-chrome-77/129907/1 "2019-10-01T02:37:03Z")

</div>

参考：[Unread tab does not update after reading](https://meta.discourse.org/t/unread-tab-does-not-update-after-reading/129162)

有不少人反映在 Android 上主题未被标记为已读的问题。

我们进行了根本原因分析，发现页面可见性 API 在 Android Chrome 77 中的行为方式发生了变化。

相关内容在此处有简要讨论：

> <https://github.com/pgilad/react-page-visibility/issues/9>
>
> Starting Chrome 77 in Android (to follow in other platforms), background tabs ar…e being "frozen" after 5 minutes of inactivity. When that tab becomes active, the event \`visibilitychange\` is no longer being fired. Instead, the new event \`resume\` is being used.
> 
> More details here: https://developers.google.com/web/updates/2018/07/page-lifecycle-api

这里有一张详细的图表解释了新的生命周期：

> **[Page Lifecycle API  |  Web Platform  |  Chrome for Developers](https://developer.chrome.com/docs/web-platform/page-lifecycle-api)**
>
> The Page Lifecycle API brings app lifecycle features common on mobile operating systems to the web. Browsers are now able to safely freeze and discard background pages to conserve resources, and developers can safely handle these interventions...

该问题的症状如下：

- 你使用 Android 设备

- 切换到其他任务 5-10 分钟

- 切换回 Discourse 时，所有内容又未被标记为已读

我在此处提供了修复方案：

> <https://github.com/discourse/discourse/commit/499472b6a0e9bd0cef4539287e9845476938cf01>
>
> Per new lifecycle https://developers.google.com/web/updates/2018/07/page-lifecyc…le-api
> 
> On Android and latest Chrome when an app transitions from "frozen" to
> active the new "resume" event fires with no accompanying "visibilitychange"
> event.
> 
> This means that often background tabs may be stuck thinking that discourse
> has no focus when, indeed, it has.
> 
> This leads to cases where no posts are marked read anymore.

理论上，这应该能解决该问题。

cc @mcwumbly / @Heather_Dudley / @Yuun

此修复将很快部署到 meta 站点，你需要完全重新加载页面才能应用该修复。

---

_[View the full topic](https://meta.discourse.org/t/topics-incorrectly-stuck-in-unread-state-on-android-in-chrome-77/129907)._
