Skip to content

Restore HEIC support through system decoders - #50

Merged
frathe merged 17 commits into
mainfrom
feature/re-add-heic-support
Sep 23, 2026
Merged

frathe merged 17 commits into
mainfrom
feature/re-add-heic-support

Conversation

@frathe

@frathe frathe commented Sep 22, 2026

Copy link
Copy Markdown
Owner

What does this change do, and why?

Restore optional HEIC/HEIF viewing through system decoders: ImageIO on macOS, Microsoft's installed HEIF/HEVC WIC extensions on Windows, and installed libheif on Linux. PicFetch remembers capability, offers a Settings recheck and offline installation guide, and uses the shared image path for browsing, thumbnails, comparison, exports, clipboard, mosaics, metadata and content analysis.

Decoding runs in bounded, cancellable child processes. The adapters preserve primary-image selection, orientation, available EXIF metadata and supported transparency. Metadata probes avoid full image creation on macOS and pixel decoding on Linux. No decoder binary or new Go module dependency is bundled.

Mixed scans continue discovering ordinary formats while the initial HEIC check runs. Unavailable sources retain their collection positions, including repeated occurrences, within a separate retention budget. Provider loss preserves collection membership and shows the HEIC guide instead of substituting a neighboring image. Shutdown joins workers and clears invalidated observations. Linux archives include a per-user desktop installer; associations, manuals and third-party notices describe optional HEIC support.

Design and evidence: docs/heic-system-decoding.md and plans/2026-09-22-system-heic.md. The branch also includes the existing PicFetch promo production record.

How was this tested?

  • Maintainer reports functional testing on Windows (including Windows ARM), macOS and Linux.
  • Confirmed UI/capability defects have observed red/green regressions; focused HEIC, drop, cancellation, collection-state and cache race checks pass.
  • Local make verify-build and native-guard inventory tests pass. Changed code has reviewed GoLand inspections, including weak warnings.
  • On a00e98a, all four Linux race partitions, Linux native guards and both Intel/Apple Silicon native suites pass, including original alpha fixtures, metadata/probe checks, worker restrictions and real analysis. Windows cache and picker regressions pass.
  • On a00e98a, Qodana's root post-suppression SARIF had zero findings, CodeQL had no open PR alerts, and fresh Codex code/security reviews completed without new findings. On 7d67e7f, fresh Codex code/security reviews completed without findings, complete CI passed (including Windows/Store), Qodana's root post-suppression SARIF has zero findings, and CodeQL has no open PR alerts. All 19 review threads are resolved.
  • The Windows CI exception has focused race regressions, an observed pre-fix workflow failure and a negative check rejecting an overly broad exclusion. Local build/vet and GoLand inspections pass. The full local Docker run passed all UI partitions; its Linux-launcher failure was a missing gio prerequisite, and that package passed after installing the tool in the disposable container.

Hosted Windows remains x64. Because that image lacks Microsoft HEIF/HEVC codecs, both Windows and Store test suites explicitly use -skip-heic-codecs, available only for Windows/Store suites in GitHub Actions. Six exact codec-dependent test names are excluded; worker restrictions, alpha metadata and portable regressions remain covered. Local native qualification and Linux/macOS CI stay strict. The maintainer explicitly accepted Windows/Store native, installed-package, codec-recovery and final-package qualification as testing after rollout; those are closed pre-release items, not claims that unexecuted tests passed. Existing automated packaging/WACK checks remain enabled. The corresponding runner review thread is resolved under this approved scope. Other separately tracked AVIF provenance/release work remains outside this disposition.

Checklist

  • Fresh full CI passes on the final PR commit (7d67e7f)
  • User-visible strings use lang.L and both translation bundles
  • Offline HEIC guides cover the new Settings and installation behavior
  • ARCHITECTURE.md describes the new package and integration
  • Qualification evidence and the accepted Windows/Store deferral are recorded in todos.md and the implementation plan

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-23T06:55:40.020625Z 7d67e7f New commits
🔒 Security Review Completed 2026-09-23T07:03:18.038484Z 7d67e7f New commits
ℹ️ 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.

@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown

Qodana for Go

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@frathe

frathe commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

First review/CI fixes pushed in d3005e9.

  • Fixed the Windows cache inventory defect: an existing non-directory reported as missing by os.Root.OpenRoot is now an incomplete inventory error. Kept the existing failing Windows partial-cleanup regression.
  • Corrected canonical URI comparison and exercised Windows sharing-violation behavior without skipping the opened-directory regression.
  • Installed the pinned analysis assets before native CI; disabled macOS matrix fail-fast so Intel evidence is retained.
  • Addressed the root post-suppression Qodana report from run 35782606207: renamed one package-name collision, explicitly typed the cgo string, and narrowly documented five false unused-export reports with confirmed cross-package callers.
  • Corrected README and both manuals, which still said HEIC was unsupported.

Verification: make verify-build, focused cache race regressions, HEIC/preferences/imaging/Settings race tests, existing manual tests, and scripts/nativeguards tests pass locally. GoLand inspections including weak warnings are clear for all eleven changed Go files. The initial hosted Linux race run passed all four partitions; CodeQL has no open PR alerts.

Still investigating: hosted macOS returns opaque alpha for premultiplied fixtures. A temporary tagged test-only probe captures the effect of removing the prem reference from copied fixtures; original corpus expectations are unchanged. Windows hosted runners lack the Microsoft HEIF class (0x80040154), so a qualified runner is needed for successful native decoder evidence. Neither qualification is being skipped to turn CI green.

The initial Codex code/security reviews are still running. A fresh review will be requested for the final head after their findings are addressed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1282f13d7a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/ui/drop.go Outdated
Comment thread internal/ui/heic.go Outdated
Comment thread internal/ui/run.go
@frathe

frathe commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

Codex findings fixed in 9287768; all three original inline findings have observed red/green regressions and are addressed in their threads.

  • Unavailable HEIC files no longer consume the image scan cap.
  • Saved collection order preserves skipped HEIC positions across removal, merge, replacement and backend loss.
  • Production shutdown joins capability, delivery and native worker lifetimes off the UI thread.
  • Intel macOS analysis children inherit the producer's verified network sandbox instead of attempting a second sandbox-exec. A required native regression checks inherited TCP/UDP denial and successful decoding; desktop worker restrictions and all process limits remain.
  • Removed the temporary alpha diagnostics. Direct ImageIO sees one frame and no alpha in the premultiplied fixtures; removing only the prem reference incorrectly exposes the grayscale alpha plane. No workaround or weakened corpus expectation was introduced.

Local verification: make verify-build; focused UI HEIC/drop/file-state/shutdown race tests; HEIC/similarity/nativeguards race tests. GoLand inspected all fourteen changed Go files, including weak warnings. Only two pre-existing duplicated transition sequences in filestate_test.go remain; they exercise distinct invariants and already have the exact test-file Qodana duplication exclusion.

Hosted evidence before this push: all Linux race partitions and validation passed on 07ecc15; all three Windows cache regressions passed after the previous fixes. The inspected post-suppression Qodana SARIF for run 35783733218 is empty, CodeQL passes, and security review completed on 07ecc15 without inline findings. These do not substitute for fresh checks on 9287768.

Outstanding native qualification: hosted Windows lacks the Microsoft HEIF decoder (0x80040154); both macOS architectures render the original premultiplied-alpha fixtures incorrectly. The user has been asked about a qualified Windows runner and whether explicit macOS refusal of these files is acceptable. Required cases remain enabled. Fresh code/security review and CI are required for this head.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9287768222

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/heic/native_darwin.c Outdated
Comment thread internal/ui/heic.go Outdated
Comment thread scripts/linuxdesktop/stage.go
Comment thread internal/imaging/heic.go Outdated
Comment thread scripts/nativeguards/main.go
Comment thread internal/heic/native_linux.c Outdated
@frathe

frathe commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

Follow-up ordering fix pushed in 65aa995. Lead review reproduced a merge-mode edge case where a repeated visible URI caused both skipped followers to be saved after its first occurrence. The new regression observed [a.jpg,b.heic,d.heic,c.jpg,a.jpg] instead of [a.jpg,b.heic,c.jpg,a.jpg,d.heic] before the fix.

Retained positions now distinguish occurrences of the same visible source. Removing one occurrence updates the retained order as well. The regression checks both the merge and subsequent removal; HEIC, app-state, viewer-state and batch-removal race tests pass. make verify-build passes, and GoLand inspections including weak warnings are clear for all three changed Go files.

On the preceding head 9287768, all Linux race partitions and validation passed, Qodana's root post-suppression SARIF had zero findings, CodeQL had no open PR alerts, and security review completed without findings. Both macOS architectures now pass the inherited-sandbox regression and native HEIC analysis. The remaining native CI failures are unchanged: missing Microsoft codecs on the hosted Windows runner and incorrect premultiplied-alpha rendition on macOS. Fresh reviews and CI are required for 65aa995.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65aa9956a3

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/ui/drop.go
Comment thread internal/ui/drop.go
Comment thread internal/ui/heic.go
Comment thread internal/ui/help/heic.go
@frathe

frathe commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

Review corrections pushed in 85fa03a:

  • macOS ImageIO now receives a validated, offset-preserving adaptation of premultiplied-alpha references, then returns restored straight-alpha channels. The original native alpha assertions remain unchanged. Native CI is the pending proof of the production path.
  • Saved collections preserve every visible and unavailable occurrence. Unavailable retention has a separate scan budget; unavailable explicit opens no longer display a neighbor; shutdown clears invalidated capability independently of queued UI delivery.
  • HEIC probe/decode requests retain the already-admitted encoded buffer boundary. Linux metadata probes no longer decode pixels.
  • Linux archives include a per-user installer with a tested desktop launcher, and CI runs the qualified Linux native guard suite with system codecs and pinned analysis assets.
  • A Windows PowerShell transport fixture gets a bounded one-minute cold-start allowance after one hosted run expired at exactly 20 seconds; all Unicode/path assertions remain.

Verification: observed red/green regressions for all confirmed behavior defects, focused UI/imaging race suites, installed-libheif native corpus/primary/transform/header checks, actual Linux archive installation and GIO launch tests for both architectures, nativeguard tooling tests, Windows cross-vet, make verify-build, and GoLand inspections including weak warnings. No new decoder, model, or native library is bundled. No original native corpus expectation or isolation requirement was weakened.

The Arch-guide report was rejected with the existing parser contract and passing no-VERSION_ID guide test. All locally verified findings have detailed thread replies; macOS alpha and Linux native CI threads remain open pending hosted evidence. The previous head's post-suppression Qodana SARIF is empty and Linux race/validation/CodeQL passed, but fresh checks and reviews are required for this head. Hosted Windows still has no registered Microsoft HEIF decoder, and this repository has no self-hosted runners.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85fa03aa18

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/heic/capability.go Outdated
Comment thread internal/ui/drop.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5fc689674e

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/heic/native_darwin.c Outdated
Comment thread internal/ui/state.go
Comment thread scripts/nativeguards/main.go
Comment thread internal/ui/load.go
@frathe

frathe commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

Final verification record for a00e98a12029bda24fc1b6dfb8df87eb45e2b8d9:

  • Fresh Codex code review completed at 23:06:13 UTC and security review at 23:10:02 UTC on 2026-09-22. Neither posted new findings; the connector added its clean-review thumbs-up.
  • 18 of 19 review threads are resolved: 17 confirmed code/CI/documentation defects fixed, and one Arch-guide false positive explained with existing passing coverage. The Windows runner finding remains open.
  • CI run 35795206229: validation, all four Linux race partitions, Linux native guards, and both Intel/Apple Silicon native suites pass. Raw native artifacts were inspected, including original alpha fixtures, metadata/probe checks, restrictions and real analysis.
  • Qodana run 35795206123: root post-suppression /qodana.sarif.json contains zero findings. CodeQL run 35795206149 passes; the current PR has no open code-scanning alerts.
  • Local make verify-build, focused race regressions and native-guard inventory tests pass. Changed code has reviewed GoLand inspection evidence, including weak warnings. The transient IDE index mismatch was repaired and affected UI files reinspected successfully. Working tree is clean.

The loop is blocked by Windows native qualification. Windows job 106972927211 fails because the hosted runner cannot activate Microsoft's HEIF decoder (HRESULT 0x80040154). Failed logs and raw events were inspected; cache and picker regressions pass. The subsequent Store suite remains unverified. No self-hosted runner is registered; a Windows runner with the official HEIF/HEVC extensions is required to close the remaining review finding. Required native tests remain intact.

This record supersedes pending final-head checks in the implementation plan without creating another commit that would invalidate the reviews. No merge or release was performed; the separately tracked package/target and AVIF provenance qualification work remains open.

@frathe

frathe commented Sep 23, 2026

Copy link
Copy Markdown
Owner Author

Review loop completed for 7d67e7f (2026-09-23).

  • Committed and pushed the maintainer-approved x64 Windows CI exception. The six exact installed-codec HEIC test names are excluded only by the explicit Windows/Store GitHub Actions option; local qualification, Linux/macOS native inventories and Windows non-codec regressions remain enabled.
  • The remaining Windows-runner finding is addressed under the maintainer's revised scope: Restore HEIC support through system decoders #50 (comment) . All 19 review threads are resolved.
  • Fresh Codex code review completed at 06:55:40 UTC and security review at 07:03:18 UTC, both on 7d67e7f, without new findings. The connector added its clean-review thumbs-up at 07:03:21 UTC.
  • Complete CI passed: https://github.com/frathe/picfetch/actions/runs/35828434487 . This includes validation, all four Linux race partitions, Linux native guards, both macOS architectures, and Windows/Store tests. Retained Windows and Store events show no failures; worker restrictions, alpha metadata, lifecycle and protocol tests pass, and the six excluded codec-dependent names do not run.
  • Qodana passed: https://github.com/frathe/picfetch/actions/runs/35828434528 . The downloaded report's root post-suppression qodana.sarif.json has zero results; the ten results in /start/ are baseline data, not current findings.
  • CodeQL passed: https://github.com/frathe/picfetch/actions/runs/35828434509 . The PR merge ref has zero open code-scanning alerts.
  • Local focused race tests, Windows x64 cross-vet, make verify-build and reviewed GoLand inspections passed. The earlier local full Docker command had one environmental failure in Linux launcher tests due to missing gio; that package passed after installing gio in the disposable container. The persistent Docker dependency follow-up remains tracked separately in todos.md; hosted full CI passes.

Windows/Store native, installed-package, codec-recovery and final-package qualification remain closed pre-release tasks by the maintainer's accepted post-rollout testing decision. This does not claim the deferred runtime tests passed. Existing automated packaging/WACK checks remain enabled.

This commit-bound record completes the pending review-loop evidence in todos.md and the implementation plan without creating another commit that would invalidate the fresh reviews. Working tree is clean. No merge or release was performed.

@frathe
frathe merged commit 02c9863 into main Sep 23, 2026
14 checks passed
@frathe
frathe deleted the feature/re-add-heic-support branch September 23, 2026 07:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7d67e7ff7f

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/ui/heic.go
Comment on lines +193 to +197
if !v.heic.capability.State().Known {
// Shutdown suppresses queued UI delivery, including invalidation
// persistence. Reconcile before Fyne flushes preferences at OnStopped.
preferences.ClearHEICObservation(v.app)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Persist completed HEIC checks during shutdown

If a capability check finishes and changes Observation but its queued UI delivery has not run when the app closes, stopHEIC marks the work stopped, causing that delivery to return without persisting the result. This branch clears unknown state but does nothing for a newly known result, so, for example, an old available observation survives even after a manual check proved the removed codec unavailable; the next launch then admits HEIC files using stale capability. Save the current observation when State().Known is true, and clear it otherwise, before Fyne's final preferences flush.

Useful? React with 👍 / 👎.

Comment on lines +21 to +24
transformed, err := inspectContainer(data)
if err != nil {
return Result{}, err
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject non-HEVC primaries in the Linux adapter

For a generic mif1 HEIF, this call validates the container but discards the primary item type returned by primaryItemProperties, then lets libheif decode whatever installed plugin handles it. Consequently an AV1- or other codec-backed generic HEIF without an explicit avif brand can be accepted on Linux, while the Windows and Darwin adapters reject primaries other than hvc1 or grid and runtime support is intended for HEVC-backed HEIF. Validate the primary item type before crossing the C boundary.

Useful? React with 👍 / 👎.

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.

1 participant