Skip to content

fix: game file download improvements and ui cleanup - #4

Merged
mgruszkiewicz merged 5 commits into
mainfrom
fix/memory-and-download-correctness
Aug 1, 2026
Merged

mgruszkiewicz merged 5 commits into
mainfrom
fix/memory-and-download-correctness

Conversation

@mgruszkiewicz

Copy link
Copy Markdown
Owner

No description provided.

Rebuild FlexBuffersParser around a lazy FlexRef reference type: values are
decoded on demand instead of materializing the whole document into a
FlexValue tree. The live manifest is ~20 MB and ~95% of it is per-chunk
hash metadata for just 208 files, so the eager parse allocated hundreds of
thousands of boxed enums on every launch (~130 MB idle footprint, 172 MB
peak; now 67 MB / 138 MB).

- all reads are bounds-checked: malformed CDN data degrades to nil/null
  instead of crashing on out-of-range subscripts
- use loadUnaligned instead of load for multi-byte reads (the old code was
  undefined behavior on unaligned offsets)
- blobs are copied out so file hashes no longer pin the manifest buffer
- drop the never-read ManifestChunk model and chunk parsing entirely
- keep the eager decode() API (now a thin wrapper over FlexRef) and add
  binary map/vector/malformed-input tests
- cancelling a download now cancels the in-flight URLSession tasks via
  withTaskCancellationHandler; previously the continuations were not
  cancellation-aware, so Cancel left up to 4 files downloading (12 h
  resource timeout) and the task group blocked on them before returning
- skip-existing and Verify & Repair now compare the manifest hash, not
  just file size, so a changed file of identical size is re-downloaded
- hashing streams the file in 1 MB chunks off the actor instead of
  memory-mapping up to 2 GB at once; the size threshold is gone and
  post-download verification covers every file
- one shared URLSession with a per-task routing delegate replaces a new
  session per downloaded file; temp files are moved, not copied
- repair path gets the same cancellation checks as full downloads (shared
  throttled loop); formatSize is nonisolated, clearing the Swift 6
  concurrency warnings
- monitor game exit with a terminationHandler installed before run()
  instead of Task.detached + waitUntilExit, which parked a cooperative
  pool thread for the whole game session
- runWineAsync timeout is a cancellable DispatchWorkItem with a weak
  process capture, so finished wine processes are released immediately
  instead of after the full 120 s deadline
- LaunchSettings no longer writes settings back to UserDefaults four
  times during load (didSet fires for assignments made while restoring)
- first-run VC++ install streams its log into the visible debug panel
- delete-prefix reuses WineManager.gptkPrefix and runs off the main
  thread; DiagnosticResult is Identifiable for stable ForEach identity
- log trimming is amortized in batches of 100
The update check only compared the channel version string against the
locally stored one, so a content patch shipped under an unchanged
version silently went unnoticed — only a manual Verify & Repair (which
hashes files directly) ever caught it. Now a manifest digest (computed
locally over each file's path/size/hash, not trusted from the CDN) is
persisted alongside the version and compared on every launch, so a
content-only change now surfaces as an update too.
…order

findWineUsername took filtered.first from an unordered contentsOfDirectory,
so a prefix holding more than one user directory resolved to whichever name
the filesystem happened to return first. A prefix can easily hold two
(crossover, since GPTK is CrossOver-derived, plus one named after the macOS
user from another Wine build), each with its own complete Palia Saved tree —
so the launcher could point its install and launch paths at a different user
than the one the game actually runs as, splitting the install from the save
data the game writes.

Wine stamps the running user's identity into [Volatile Environment] on every
wineboot, and that value is what %LOCALAPPDATA% resolves to inside the
prefix, so user.reg is now the source of truth. The directory scan remains a
fallback for prefixes without a usable user.reg, but is no longer
order-dependent: directories only (a stray .DS_Store can't be mistaken for a
user), preferring a user that already holds a PaliaClient.exe so an
already-split prefix self-heals, then sorted for a stable result.
@mgruszkiewicz
mgruszkiewicz merged commit 368865a into main Aug 1, 2026
2 checks passed
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