dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.26k stars 1.76k forks source link

Fix android image loading race condition and improve logging #25870

Open albyrock87 opened 1 week ago

albyrock87 commented 1 week ago

Description of Change

This PR aims to solve three issues:

  1. Switching between Shell Tabs destroys the Fragment causing unwanted image unloading: Reloading images upon re-attach was handled in #24023 but we can provide a better UX here and avoid flashes while going back to the initial tab.
  2. Random flashes while scrolling collection view caused by a race condition in image loading: Glide is race-condition free, but we were setting the Drawable asynchronously in the next loop, this may generate glitches under some scrolling condition in collection view
  3. It's really hard to debug our beloved Glide integration: I've added proper logging mechanics which can be enabled via adb before running the application:
    adb shell setprop log.tag.Glide VERBOSE
    adb shell setprop log.tag.MauiCustomTarget VERBOSE
    adb shell setprop log.tag.MauiCustomViewTarget VERBOSE

    Example logs:

    D Glide   : Finished loading BitmapDrawable from MEMORY_CACHE for FontModel{color=#FF000000, glyph='f111', textSize=84.0, typeface=android.graphics.Typeface@898fd220} with size [-2147483648x-2147483648] in 0.202625 ms
    V MauiCustomViewTarget: onResourceReady: FontModel{color=#FF000000, glyph='f111', textSize=84.0, typeface=android.graphics.Typeface@898fd220}

Issues Fixed

14587

25783

jsuarezruiz commented 6 days ago

/azp run

azure-pipelines[bot] commented 6 days ago
Azure Pipelines successfully started running 3 pipeline(s).
rmarinho commented 4 days ago

/rebase

rmarinho commented 4 days ago

/azp run

azure-pipelines[bot] commented 4 days ago
Azure Pipelines successfully started running 3 pipeline(s).
rmarinho commented 2 days ago

/rebase

rmarinho commented 2 days ago

/azp run

azure-pipelines[bot] commented 2 days ago
Azure Pipelines successfully started running 3 pipeline(s).