-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[Bug]: Wallpaper loading on launch is delayed #26511
[Bug]: Wallpaper loading on launch is delayed #26511
Comments
I've tried to verify this issue, and I was blocked by a crash: #26723. |
#26723 is verified as fixed on the latest Nightly 106 updated from main locally. The app no longer crashes on startup when a wallpaper is selected. However, in the locally updated Nightly build, this issue is still reproducible: after launching the app, the wallpaper is still displayed with a short delay. Talked to @Mugurell and we will wait for the official Nightly build containing the fix for the #26723 crash to become available on PlayStore of task index, and re-test this. screen-20220901-121827_Trim.mp4 |
I indeed can reproduce again the slow wallpapers after the fix for #26723 which meant moving the operations to the Main thread. Tried to take a profile of this but I don't find the interesting details in it - https://share.firefox.dev/3TwPa4x My thoughts on why this might happen - Dispatchers.Main (current) vs Dispatchers.IO (previously used which showed significantly faster execution) revolves more around context switching (loading the bitmap happens on an IO thread) causing this delay with the Main thread probably having a long queue to execute at startup. Will try some refactoring. |
Running on an IO thread and then switching to Main with a simple
here does show a 50-100ms delay for just starting the runnable execution while if remaining with IO it's basically instant. But of course we should not update Views from other threads (curious that this works). |
Split loading the bitmap from storage and actually setting it in two operations with one that can run in parallel with onCreateView for HomeFragment and one that can be used serially on the main thread to actually set the wallpaper. This seems the best compromise to ensure that everytime the homescreen is shown it will have the wallpaper set but does affect the performance - there is a delay in showing HomeFrament to account for waiting for the wallpaper to be set.
Split loading the bitmap from storage and actually setting it in two operations with one that can run in parallel with onCreateView for HomeFragment and one that can be used serially on the main thread to actually set the wallpaper. This seems like the best compromise to ensure that everytime the homescreen is shown it will have the wallpaper set but does affect the performance - there is a delay in showing HomeFragment to account for waiting for the wallpaper to be set. In testing the new delay seems close to the one from the initial wallpapers implementation. See more in mozilla-mobile#26794.
This should squeeze the most performance for users who haven't set a wallpaper.
Previously we were waiting until the AppState is updated with the wallpaper previously chosen by the user (option persisted in SharedPreferences). It is possible though that the previously chosen wallpaper has expired (or for other reasons it is unavailable) in which case the AppState will be updated with the default wallpaper while in SharedPreferences we still keep the name of unavailable wallpapers.
…listeners In the scenario of setting the wallpaper from both the observer and the fragment there would be two layout listeners set for scaling the bitmap with only the first being used immediately and the second being left to observe future changes as when the keyboard is shown moment at which it would trigger an unexpected wallpaper scaling. By avoiding the apply the wallpaper from the observer and only applying it from HomeFragment there will be only one layout change listener and so the above issue will also be avoided.
Verified as fixed on Nightly 107.0a1 from 09/20 with Google Pixel 6 (Android 13). The wallpaper set is displayed on homepage as soon as the app is opened, and the user does not notice a delay any more. 26511.mp4 |
…and observe updates
Steps to reproduce
Expected behaviour
The wallpaper loads without visual issues or significant delay, given a good and stable network connection.
Actual behaviour
The wallpaper loading on homepage is delayed with 1-3 seconds when launching the app, even with a good and stable network connection.
The issue occurs after every restart, not only the first launch.
Device name
Xiaomi 12 Pro
Android version
Android 12
Firefox release type
Firefox Nightly
Firefox version
latest Nightly 105.0a1 from 08/17
Device logs
No response
Additional information
Also reproduced with: Samsung Galaxy A32 (Android 11), Samsung Galaxy S22 Ultra (Android 12), Lenovo Yoga Tab 11 (Android 11).
Screenrecorder-2022-08-17-17-30-36-932_Trim.mp4
┆Issue is synchronized with this Jira Task
The text was updated successfully, but these errors were encountered: