hotfix/cp-12674-remote-images-are-decoded-at-full-size-without-downsampling

UN
17d ago
+697-292

Optimize bitmap decoding to reduce memory usage in NotificationService, InboxView and AppBanner


[!NOTE]
Medium Risk
Touches notification rendering and several banner/inbox image paths; behavior should be equivalent but Glide and sampled decode can differ on GIFs, errors, and timing versus the old manual loaders.

Overview
Reduces peak memory when loading remote images by decoding at on-screen dimensions instead of full resolution, which previously could trigger OOM on large assets.

Adds BitmapUtils for sampled URL decoding and wires NotificationService to use it for big-picture media, text-with-image layouts, and carousel prefetch, with explicit max sizes and bitmap recycling after carousel saves.

App banner and inbox UI drop hand-rolled HttpURLConnection / BitmapFactory background threads in favor of Glide (disk cache, load listeners, main-thread into()), including banner block images, backgrounds, and inbox list thumbnails at 50dp with ImageView tags so rebound rows don’t show stale channel icons.

Smaller inbox fixes: carousel removeAllViews() on bind, HTML text uses COMPACT mode plus trailing blank-line cleanup, and inbox banner show retries are capped at 50 with a log when the host never becomes ready.

Reviewed by Cursor Bugbot for commit f1df7c83ec165f4be35edbb3692cd5193506b1f8. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Reduces peak memory usage when loading remote images by decoding them at display size instead of full resolution. Previously, notification media, carousel images, and banner/inbox images were decoded at full size regardless of their on-screen size, which could cause OOM crashes on large images. UI surfaces now use Glide, which handles downsampling and caching, and NotificationService uses the new BitmapUtils for sampled decoding.

  • NotificationService decodes big-picture, text-with-image, and carousel images to device-specific target dimensions and recycles carousel bitmaps after writing them to disk.
  • App banner and inbox background and image-block loads move from manual BitmapFactory threads to Glide, dropping the GIF-specific path for plain Glide loading.
  • Inbox list thumbnails load via Glide with a 50dp override, and a view tag prevents stale channel icons from landing on rebound rows.
  • Carousel adapters clear the body view on rebind, and inbox HTML uses COMPACT mode with trailing blank lines stripped.
  • Inbox detail banner show retries are capped at 50 attempts with a log entry when none succeed.