Skip to content

fix: load pubky avatars up to 5 mb - #1586

Merged
ovitrif merged 2 commits into
masterfrom
fix/pubky-avatar-size
Dec 3, 2026
Merged

ovitrif merged 2 commits into
masterfrom
fix/pubky-avatar-size

Conversation

@ovitrif

@ovitrif ovitrif commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Twin: synonymdev/bitkit-android#2252
Source: qa, synonymdev/bitkit-android#2248

Description

  • Fixes Pubky profile and contact avatars between 1 MiB and 5 MiB not loading, because the image fetch was capped at 1 MiB while Pubky App accepts avatar uploads up to 5 MiB (a 1,259,708-byte 1024×1024 PNG avatar failed with response exceeds the 1048576-byte limit)
  • Uses the same 5 MiB limit for displaying avatars and for moving a Bitkit avatar to pubky.app, so the two no longer drift
  • Raises the image disk cache from 32 MiB to 160 MiB so it still holds 32 avatars at the new limit, because it keeps the downloaded file

Out of Scope

None.

Design

N/A — no UI changes.

Preview

N/A — no UI changes.

QA Notes

Setup

A Pubky identity whose profile avatar is between 1 MiB and 5 MiB (for example a 1024×1024 PNG exported from Pubky App).

Journeys

N/A — not drivable; see Manual Tests.

Manual Tests

  • 1. Import a Pubky identity from Pubky Ring whose avatar is over 1 MiB → the avatar shows on Profile and in Contacts — needs a real homeserver profile with a large avatar

Automated Checks

  • added PubkyImageCacheTests.swift — a 1,259,708-byte image loads
  • ran PubkyImageCacheTests.swift

Evidence

Gaps

    1. not yet run on a device with this build

Models used

  • Planning/scoping: Claude Opus 5.5 (reasoning: medium)
  • Implementation: Claude Opus 5.5 (reasoning: medium)
  • Review: Gemini 4 Neon (reasoning: high)
  • Review rounds: 2

Pubky App accepts avatar uploads up to 5 MiB, but the image view
stopped at 1 MiB, so a 1.26 MB avatar never showed. Use one 5 MiB limit
for displaying avatars and for moving a Bitkit avatar to pubky.app.

Verified: xcodebuild test -only-testing:BitkitTests/PubkyImageCacheTests
@ovitrif ovitrif added this to the 3.3.0 milestone Dec 3, 2026
@ovitrif ovitrif self-assigned this Dec 3, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T17:36:59.547417Z c1a29dc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ovitrif
ovitrif requested review from a team, coreyphillips and jvsena42 and removed request for a team December 3, 2026 17:35
@greptile-apps

greptile-apps Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] This PR appears safe to merge.

Summary

Raises the Pubky avatar download limit from 1 MiB to 5 MiB.

  • Pubky avatars up to 5 MiB can load and move with one shared limit.

Reviews (1) · Last reviewed commit: "fix: load pubky avatars up to 5 mb" · Reviewed by Greptile

@talosmachina talosmachina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings. Raises the Pubky image fetch and decode cap from 1 MiB to 5 MiB and makes the avatar move to pubky.app read the same constant. Reviewed c1a29dc, light tier, static.

What I checked, and 4 candidates I ruled out

Read in full: Bitkit/Components/PubkyImage.swift (loader, decoder, PubkyImageCache), PubkyAppProfileStore.moveAvatar, PubkyService.fetchFile and PaykitSdkService.fetchFile
Call sites traced: every reader of PubkyImagePolicy.maxDownloadBytes: the descriptor fetch and the blob fetch in loadImageOffMain/resolveImageData, the PubkyImageDecoder size gate, the cache's default maxFileBytes, and now avatarMaxBytes. All four move together, so the fetch, decode and cache gates cannot disagree.
Build: not built here; this repo is reviewed from the code and from CI only, and iOS does not build on Linux.
CI: SwiftFormat, validate and Greptile green; Run Tests and Run Integration Tests still pending at review time.

Ruled out

  • The bounded fetch refusing 5 MiB: moveAvatar already called the same fetchPubkyFileBounded with 5 MiB before this PR, so the FFI path accepts that bound.
  • Old 1 MiB failures stuck as permanent: failures lives in memory only, so a rejection remembered by an older build does not survive the update.
  • Disk cache holding fewer avatars: diskCacheBytes stays 32 MiB, so a run of 5 MiB avatars fits about six before LRU trimming; that only costs refetches, and small avatars (the common case) are unaffected.
  • Decode memory for a 5 MiB PNG: CGImageSourceCreateThumbnailAtIndex with maxPixelSize: 512 keeps the retained image small; the transient decode is bounded by the dimensions pubky.app itself accepts, and no failure path in this diff depends on it.

Merge confidence: 4/5, testImageOverOneMebibyteLoads covers the change but the unit test run had not finished when I reviewed.

Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the runtime does not report it)

@coreyphillips coreyphillips left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two independent reviews, nothing blocking a merge.

worth doing, does not block

  • Disk cache now keeps only about six full-size avatars (Bitkit/Components/PubkyImage.swift:131-134)

Comment thread Bitkit/Components/PubkyImage.swift Resolved
The disk cache keeps the downloaded file, so at the 5 MiB limit the
32 MiB budget held only about six avatars and evicted the rest on the
next launch. Raise it to 160 MiB.

Verified: none (one constant; CI builds and runs PubkyImageCacheTests)
@ovitrif
ovitrif requested a review from coreyphillips December 3, 2026 18:18

@coreyphillips coreyphillips left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked after 1 new commit (992378b). Nothing blocking remains.

addressed

  • Disk cache now keeps only about six full-size avatars (Bitkit/Components/PubkyImage.swift:131-134). Fixed: PubkyImage.swift:135 now sets diskCacheBytes to 160 MiB, which is 32 × the 5 MiB maxFileBytes cap that store enforces at :279. trimDiskCache (:409) evicts only while the total is over maxDiskBytes, so 32 files at the full limit fit without eviction. No test depends on the old 32 MiB default.

@ovitrif

ovitrif commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

Merged: approved by @coreyphillips on this head, required checks green (unit tests passed on a rerun after unrelated flaky failures), no open threads.

@ovitrif
ovitrif merged commit 5261746 into master Dec 3, 2026
21 of 23 checks passed
@ovitrif
ovitrif deleted the fix/pubky-avatar-size branch December 3, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants