Fix 5: iOS Safari scoped asset loading and memory management

- New Platform.gd autoload: is_ios_safari() detects iPhone/iPad Safari
  via JavaScriptBridge UA check (no Chrome/CriOS), gating all iOS memory paths
- ModelCache.release_model(url, etag): evicts a model from in-memory cache
  on iOS Safari when a unit leaves the board; no-op on other platforms so
  disk cache is always preserved for fast reload
- unit_mesh_builder: stores resolved model URL+ETag per unit (_unit_model_urls,
  _unit_model_etags); calls ModelCache.release_model in the to_remove loop so
  PackedScene refs are freed as soon as the unit is pooled or freed
- ContentCache.get_model_url_for_definition: stub for looking up a card's
  Model3D CDN URL without a loaded unit dict (foundation for future eviction paths)

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-05-20 22:35:05 -04:00
co-authored by Claude Happy
parent 93e3c8b0db
commit c8c3666d26
5 changed files with 64 additions and 0 deletions
@@ -62,6 +62,23 @@ func get_definition(id: String) -> Dictionary:
return _defs.get(id, {})
## Return the CDN URL for the first Model3D asset in a card definition.
## Returns "" if the definition is not cached or has no Model3D asset.
## Intended for iOS Safari memory-management paths that need the URL without a
## loaded unit dict (e.g. pre-eviction before a unit is placed).
func get_model_url_for_definition(definition_id: String) -> String:
var def := get_definition(definition_id)
for asset: Variant in def.get("assets", []):
var d: Dictionary = asset as Dictionary
if d == null:
continue
if str(d.get("assetType", "")) == "Model3D":
var url: String = str(d.get("cdnUrl", "")).strip_edges()
if not url.is_empty() and url.to_lower() != "null":
return url
return ""
## True if the definition is cached.
func has_definition(id: String) -> bool:
return _defs.has(id)