# Laggy scrolling on Android

**URL:** https://meta.discourse.org/t/laggy-scrolling-on-android/210217
**Category:** Bug
**Created:** [November 26, 2021, 8:57am UTC](https://meta.discourse.org/t/laggy-scrolling-on-android/210217 "2021-11-26T08:57:54Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [November 26, 2021, 8:57am UTC](https://meta.discourse.org/t/laggy-scrolling-on-android/210217/1 "2021-11-26T08:57:55Z")

</div>

Hello,

With the latest update [1b5f26e0ab](https://github.com/discourse/discourse/commits/1b5f26e0ab9b50af03c94f797791fc12e7bd94b4) I used all day and the problem appear yesterday night. So I think the issue in one of the last few commits.

It seems to happens when I touch and start scrolling. The scrolling is not start immediately.

The issue seems to only on Android on both view (mobile and desktop) and the PWA and browser too.

It affect on the whole site where scrolling available.

My device:  
Android 10  
Chrome 96.0.4664.45

Thanks 🙂

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [November 26, 2021, 12:55pm UTC](https://meta.discourse.org/t/laggy-scrolling-on-android/210217/2 "2021-11-26T12:55:04Z")

</div>

This is very interesting, thanks for reporting! As far as I’m aware, the only recent commit which affects scrolling would be:

> <https://github.com/discourse/discourse/commit/fd93d6f955302907aa5e6ee96ff24e038464f04a>
>
> \- Remove JQuery
> \- Remove legacy \`document.webkitHidden\` support. None of our cu…rrently supported browsers need this
> \- Use \`passive\` event listeners. These allows the browser to process the events first, before passing control to us
> \- Add a new \`unseenTime\` parameter. This allows consumers to request a delay before being notified about the browser going into the background
> \- Add a method for removing a callback
> \- Fire the callback when presence changes in either direction. Previously it would only fire when the user becomes present after a period of inactivity.
> \- Ensure callbacks are only called once for each state change. Previously they would be called every 60s, regardless of the value
> \- Listen to the \`visibilitychanged\` and \`focus\` events, treating them as equivalent to user action. This will make messagebus re-activate more quickly when switching back to a stale tab
> \- Add test helpers
> \- Delete the unused \`discourse/lib/page-visible\` module.
> \- Call message-bus's onVisibilityChange API directly, rather than dispatching a fake event on the \`document\`

But if anything, I would have expected that to make scrolling **smoother** , not worse! (I switched this particular feature to use ‘passive’ event listeners, rather than blocking event listeners)

Do you have the same problem on [try.discourse.org](http://try.discourse.org)?

As an experiment, I just made a theme here on Meta which removes those updated event listeners. [https://meta.discourse.org/?preview\_theme\_id=260](https://meta.discourse.org/?preview_theme_id=260) (Named “Experiment - remove scroll listener” in the hamburger) Does this theme fix the lagging for you?

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [November 26, 2021, 1:04pm UTC](https://meta.discourse.org/t/laggy-scrolling-on-android/210217/3 "2021-11-26T13:04:03Z")

</div>

Hi David,

Thank you for the quick response. Unfortunately there is the same issue on try and the Experiment - remove scroll listener theme too. 😕

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [November 26, 2021, 1:05pm UTC](https://meta.discourse.org/t/laggy-scrolling-on-android/210217/4 "2021-11-26T13:05:56Z")

</div>

Thanks for checking! In a way I’m glad that didn’t fix it, because I have no idea why that change would cause worse performance! 😅

I’ll do another comb through recent commits and see if I can spot anything suspicious 👀

Would you mind letting us know the make/model of your device, so I can try to reproduce in a simulator?

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [November 26, 2021, 1:10pm UTC](https://meta.discourse.org/t/laggy-scrolling-on-android/210217/5 "2021-11-26T13:10:19Z")

</div>

On second thought, yes, it is positive 😀

> [@david](#):
>
> Would you mind letting us know the make/model of your device, so I can try to reproduce in a simulator?

Sure my device is a Huawei P20 Pro 🙂

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [November 26, 2021, 1:30pm UTC](https://meta.discourse.org/t/laggy-scrolling-on-android/210217/6 "2021-11-26T13:30:57Z")

</div>

Cant repro this on my phone on either Chrome or Firefox.

---

<div class="post-metadata">

### Author: ![Osama](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osama/32/98013_2.png) [@Osama](https://meta.discourse.org/u/Osama)
#### Post date: [November 26, 2021, 4:03pm UTC](https://meta.discourse.org/t/laggy-scrolling-on-android/210217/7 "2021-11-26T16:03:30Z")

</div>

I can repro here on Meta using my Pixel 4 XL running Android 12. I didn’t notice it until I read this topic. The best way to see it is to scroll short distances (~2cm on the screen) repeatedly.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [November 26, 2021, 4:34pm UTC](https://meta.discourse.org/t/laggy-scrolling-on-android/210217/8 "2021-11-26T16:34:52Z")

</div>

I made this improvement:

[https://github.com/discourse/discourse/commit/4d3eb3f1acfc307e808c4f788c8683cc5c2da316](https://github.com/discourse/discourse/commit/4d3eb3f1acfc307e808c4f788c8683cc5c2da316)

Which is now deployed to meta. Does that feel any better @Don?

That issue isn’t new though, so I’m not sure why it only started being noticeable in the last couple of days 🤔

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [November 26, 2021, 4:37pm UTC](https://meta.discourse.org/t/laggy-scrolling-on-android/210217/9 "2021-11-26T16:37:33Z")

</div>

David now it is perfect 🙂 Thank you!

I saw yesterday a commit about software update prompt 🤔 Maybe that is related with this issue?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [November 26, 2021, 4:41pm UTC](https://meta.discourse.org/t/laggy-scrolling-on-android/210217/10 "2021-11-26T16:41:46Z")

</div>

Glad to hear it!

> [@Don](#):
>
> about software update prompt

Oh yes, you’re absolutely right! I totally missed that. [This commit](https://github.com/discourse/discourse/commit/1166afa4e867a7f397c9c3f8e46b6d02f2aecb4a) from yesterday refactored the `--header-offset` logic so that it runs all the time, rather than ‘only when docked’. That slowed down scroll performance. My fix made that logic more efficient, so that’s why it’s working now. 👍

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [November 26, 2021, 5:18pm UTC](https://meta.discourse.org/t/laggy-scrolling-on-android/210217/11 "2021-11-26T17:18:12Z")

</div>


