Share Blob buffer for streamed PICT instead of copying bytes#68
Conversation
The Toolbox PICT path already streams opcodes straight to the window via a getPicProc bottleneck (no full-frame offscreen), but MakeImageFromPictBytes copied the whole PICT byte vector into ToolboxPictBytesPayload — a second full-file copy resident for the Image's lifetime on top of the source Blob. Hold the source Blob (refcounted Managed<BlobRecord> handle) in the payload and stream from its buffer directly, so resident PICT bytes drop from ~2x file size to 1x. No behavior change; the streamed bytes are identical. Renames MakeImageFromPictBytes -> MakeImageFromPictBlob to match. Verified: builds clean for retro68-68k (LokaAppleToolboxCore and LokaSimpleViewer68K link). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41eb09d2f1
ℹ️ 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".
There was a problem hiding this comment.
Pull request overview
Reduces memory overhead in the Classic Toolbox PICT rendering path by making the native image payload retain the source Blob and stream directly from its buffer, instead of copying the full PICT byte vector into a second resident allocation.
Changes:
- Replace
MakeImageFromPictBytes(...)withMakeImageFromPictBlob(...)and update the Toolbox call site. - Change the PICT streaming payload to hold a
loka::core::resource::Blob(shared buffer) rather than an ownedstd::vector<unsigned char>. - Update the Toolbox PICT streaming read/draw helpers to read via
payload->blob.bytes().
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apple/toolbox/src/ToolboxPlatformContext.cpp | Switches Toolbox image creation to pass the source Blob through to the native PICT image factory. |
| apple/toolbox/src/ToolboxNativeImage.hpp | Updates the native PICT payload structure to retain a Blob instead of copying bytes; renames the factory API to take a Blob. |
| apple/toolbox/src/ToolboxNativeImage.cpp | Implements MakeImageFromPictBlob and stores the Blob in the payload for lifetime sharing. |
| apple/toolbox/src/context/ToolboxImageViewContext.cpp | Streams PICT bytes from payload->blob.bytes() in the getPicProc path instead of from an owned byte vector. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Review follow-up. Sharing the source Blob desynced the streamed bytes from the width/height parsed at creation if the Blob was later mutated via setBytes()/mutableBytes(). Share only completed+immutable Blobs (keeping the zero-copy win for the common case) and copy into an owned snapshot otherwise, restoring the snapshot semantics the macOS/Win32 decoders already have. Also drop the now-unused <vector> from ToolboxNativeImage.hpp and include it directly in ToolboxImageViewContext.cpp where std::vector is named. Verified: retro68-68k builds clean (LokaAppleToolboxCore + LokaSimpleViewer68K). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks — addressed the review feedback in 7bd70f9. Mutable-Blob aliasing (Codex P2 / Copilot): you're right that sharing the source Unused Re-verified: |
Review notes(Claude Fable 5 / 2026-07-07)別セッションの自著 PR のため approve ではなくコメントで残す。結論: マージ可。指摘は非ブロッキング 1 件 + プロセスメモ 1 件で、いずれも follow-up でよい。 確認したこと
指摘(非ブロッキング)共有ガードは作成時点のチェックで、record は凍結されない。 対処案(どちらか、別 PR で可):
プロセスメモruntime パリティ(エミュレータでの PICT 描画)未実施の明示は検証ポリシーに沿っている。追跡先の名指しがあると完璧 — Flow シナリオハーネス構想か #46 に一行で紐づけておくとよい。 |
cubenoy22
left a comment
There was a problem hiding this comment.
System J1-7.1 (MAME)にて3072KB確保した場合に修正前は開けなかった700KBのPICTが修正後は開けるようになっていたことを確認 ✅
What
The Toolbox PICT path already streams opcodes straight to the window through a
getPicProcbottleneck (StdGetPic) — it never allocates a full-frame offscreen. ButMakeImageFromPictBytescopied the entire PICT byte vector intoToolboxPictBytesPayload, so a second full-file copy stayed resident for theImage's lifetime on top of the sourceBlob.This makes the payload hold the source
Blob(a refcountedManaged<BlobRecord>handle) and stream from its buffer directly.MakeImageFromPictBytes→MakeImageFromPictBlob(only caller updated)Scope
One failure mode, Toolbox-local:
ToolboxNativeImage.{hpp,cpp},ToolboxImageViewContext.cpp, one call site inToolboxPlatformContext.cpp. Does not touchBlob's public contract.This is the stepping stone noted in #32 toward reader/pull-first resource access; the larger
bytes()→reader()contract change is captured there and deferred to the LPK design.Verification
Refactor (behavior-preserving), so the bar is before/after parity. Builds clean for
retro68-68k:LokaAppleToolboxCorecompiles andLokaSimpleViewer68Klinks. Runtime PICT render parity in an emulator not exercised in this PR.🤖 Generated with Claude Code