Modern Apps git

← Modern-Apps.git

various fixes

Commit
0e29b9b0b87c37e57ce2ac7e229c210b1e401f2b
Author
vayun-mathur <[email protected]>
When
2026-10-20 04:55 UTC (1 month ago)
Parents
87752c0

Diff

games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorScreen.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorScreen.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorScreen.ktindex 6b560bb46b..80c94b9951 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorScreen.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/YuuEditorScreen.kt@@ -51,7 +51,6 @@ import com.vayunmathur.games.hub.ui.yuu.YuuCategory import com.vayunmathur.games.hub.ui.yuu.YuuEditorActions import com.vayunmathur.games.hub.ui.yuu.YuuEditorUiState import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.FilterChip import com.vayunmathur.library.ui.IconArrowDownward@@ -59,6 +58,7 @@ import com.vayunmathur.library.ui.IconArrowUpward import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconRotateLeft import com.vayunmathur.library.ui.IconRotateRight+import com.vayunmathur.library.ui.IconSave import com.vayunmathur.library.ui.IconUnfoldLess import com.vayunmathur.library.ui.IconUnfoldMore import com.vayunmathur.library.ui.IconZoomIn@@ -92,14 +92,30 @@ fun YuuEditorScreen(      AppScaffold(         title = {-            Text(-                stringResource(-                    if (state.editingId == null) R.string.yuu_new else R.string.yuu_edit_title-                ),-                fontWeight = FontWeight.Bold,+            OutlinedTextField(+                value = name,+                onValueChange = { name = it; nameError = false },+                label = { Text(stringResource(UiR.string.name)) },+                singleLine = true,+                isError = nameError,+                supportingText = if (nameError) {+                    { Text(stringResource(R.string.yuu_name_required)) }+                } else null,+                modifier = Modifier.fillMaxWidth(),             )         },         onNavigateBack = actions::onDismiss,+        actions = {+            IconButton(+                onClick = {+                    if (name.isBlank()) {+                        nameError = true+                    } else {+                        actions.onSave(name, draft.toConfig())+                    }+                }+            ) { IconSave() }+        },         scrollBehavior = appBarScrollBehavior(),     ) { padding ->         Column(@@ -116,7 +132,7 @@ fun YuuEditorScreen(                 ) {                     Box(                         modifier = Modifier.fillMaxWidth()-                            .heightIn(max = 240.dp),+                            .heightIn(max = 180.dp),                         contentAlignment = Alignment.Center,                     ) {                         YuuAvatar3D(@@ -153,34 +169,7 @@ fun YuuEditorScreen(                     )                 }             }-            // Zone 2: name + save on one compact row.-            Row(-                modifier = Modifier.fillMaxWidth(),-                horizontalArrangement = Arrangement.spacedBy(6.dp),-                verticalAlignment = Alignment.CenterVertically,-            ) {-                OutlinedTextField(-                    value = name,-                    onValueChange = { name = it; nameError = false },-                    label = { Text(stringResource(UiR.string.name)) },-                    singleLine = true,-                    isError = nameError,-                    supportingText = if (nameError) {-                        { Text(stringResource(R.string.yuu_name_required)) }-                    } else null,-                    modifier = Modifier.weight(1f),-                )-                Button(-                    onClick = {-                        if (name.isBlank()) {-                            nameError = true-                        } else {-                            actions.onSave(name, draft.toConfig())-                        }-                    },-                ) { Text(stringResource(UiR.string.save)) }-            }-            // Zone 3: category rail (never scrolls the screen).+            // Zone 2: category rail (never scrolls the screen).             LazyRow(horizontalArrangement = Arrangement.spacedBy(6.dp)) {                 items(YuuCategory.entries) { cat ->                     FilterChip(@@ -190,7 +179,7 @@ fun YuuEditorScreen(                     )                 }             }-            // Zone 4: the ONLY scrollable area — the option picker.+            // Zone 3: the ONLY scrollable area — the option picker.             Column(                 modifier = Modifier.fillMaxWidth().weight(1f).verticalScroll(rememberScrollState()),                 verticalArrangement = Arrangement.spacedBy(6.dp),@@ -211,7 +200,7 @@ fun YuuEditorScreen( }  /** Preview aspect (w/h): avatar and stepper overlay share it — keep in sync. */-private const val PREVIEW_ASPECT = 1.5f+private const val PREVIEW_ASPECT = 2.0f  private fun YuuCategory.labelRes(): Int = when (this) {     YuuCategory.Face -> R.string.yuu_cat_face
maps/src/main/rust/src/graph_part2.rs
diff --git a/maps/src/main/rust/src/graph_part2.rs b/maps/src/main/rust/src/graph_part2.rsindex f4219a4e5f..8a6b3c1050 100644--- a/maps/src/main/rust/src/graph_part2.rs+++ b/maps/src/main/rust/src/graph_part2.rs@@ -103,11 +103,7 @@ impl Graph {             }             None         };-        let _nodes = if nodes_view.is_some() {-            ptr::null()-        } else {-            nodes_region.base()-        };+        let _nodes = nodes_region.base();          // edges.bin's five sections, computed forwards from the metadata counts.         // The total-length assertion below is what replaces v3's self-locating@@ -149,11 +145,11 @@ impl Graph {         if edges_region.len as u64 != want_edges {             return None;         }-        let edges = if edges_view.is_some() {-            ptr::null()-        } else {-            edges_region.base()-        };+        // Table base is the file base unconditionally: only the record array+        // itself is blocked-compressed under v7 (see the single-archive+        // `assemble` — same fix, same on-device SIGSEGV). The per-record+        // readers branch onto the inflated view (see `edge_rec`).+        let edges = edges_region.base();         let escape_first = unsafe { edges.add(escape_first_off as usize) };         let escapes = unsafe { edges.add(escapes_off as usize) };         let names = EdgeBitmap {@@ -309,8 +305,14 @@ impl Graph {             _ => (ptr::null(), None),         };         // A wrong-length elevation.bin is dropped, not kept mapped: nothing should read a stale-        // vintage's bytes, and holding the region alive would imply it is usable.-        let elevation_region = if elevation.is_null() { None } else { elevation_region };+        // vintage's bytes, and holding the region alive would imply it is usable. A valid v7+        // blocked view has a null raw pointer by design (see `node_elevation`), so it must not+        // drop the region its frames live in.+        let elevation_region = if elevation.is_null() && elevation_view.is_none() {+            None+        } else {+            elevation_region+        };          let nodes = nodes_region.base();         // --- Derived tables (identical formulas to the C++ init) ---
maps/src/main/rust/src/graph_part2b.rs
diff --git a/maps/src/main/rust/src/graph_part2b.rs b/maps/src/main/rust/src/graph_part2b.rsindex b08797183a..a1c3c77a96 100644--- a/maps/src/main/rust/src/graph_part2b.rs+++ b/maps/src/main/rust/src/graph_part2b.rs@@ -52,6 +52,10 @@ impl Graph {     /// Deliberately asymmetric with [`Graph::node`], which is unchecked: the     /// sentinel index `node_count` is a *valid* read that this method rejects, and     /// [`Graph::edge_range`] depends on being able to make it.+    ///+    /// Note: under v7 the raw table pointer is still the section base (never+    /// null), so this null check means "graph without a node table", not+    /// "blocked layout" (see `load`/`assemble`).     #[inline]     pub fn get_node(&self, id: u32) -> NodeMaster {         if self.nodes.is_null() || id >= self.node_count {
maps/src/main/rust/src/graph_part3.rs
diff --git a/maps/src/main/rust/src/graph_part3.rs b/maps/src/main/rust/src/graph_part3.rsindex 21f3129801..4e67987983 100644--- a/maps/src/main/rust/src/graph_part3.rs+++ b/maps/src/main/rust/src/graph_part3.rs@@ -205,6 +205,10 @@ impl Graph {     /// `source`, into `out`. Returns `Some((count, is_reversed))`, with `count == 0`     /// when the edge stores no polyline. `out` must hold at least 256 points.     ///+    /// The `edges.is_null()` arm means "graph without an edge table", not+    /// "blocked layout": under v7 the base is still the section base (see+    /// `load`/`assemble`), and the per-record path reads the inflate cache.+    ///     /// `source` must really be the node whose range `edge_idx` falls in. It seeds     /// the decode, so a wrong one silently draws the polyline from the wrong place.     /// Every call site iterating a node's edge range already has it; the one that
maps/src/main/rust/src/graph_part4.rs
diff --git a/maps/src/main/rust/src/graph_part4.rs b/maps/src/main/rust/src/graph_part4.rsindex 13bafa31e3..70832f8657 100644--- a/maps/src/main/rust/src/graph_part4.rs+++ b/maps/src/main/rust/src/graph_part4.rs@@ -82,7 +82,12 @@ impl Graph {         }         let magic = u32::from_le_bytes([meta[0], meta[1], meta[2], meta[3]]);         let version = u32::from_le_bytes([meta[4], meta[5], meta[6], meta[7]]);-        if magic != GRAPH_MAGIC || version != GRAPH_VERSION {+        // Accept the same range as the multi-file `load` and the archive+        // `check_counts`: v6 raw tables still read directly, v7 blocked.+        // Rejecting v6 here (exact `== GRAPH_VERSION`) refused every+        // pre-blocked archive on the single-archive path, including the+        // minimal-v6 round-trip test.+        if magic != GRAPH_MAGIC || !(GRAPH_VERSION_MIN..=GRAPH_VERSION).contains(&version) {             return None;         }         let u64_at = |o: usize| {@@ -167,11 +172,14 @@ impl Graph {         if edges_bytes.len() as u64 != want_edges {             return None;         }-        let edges_ptr = if edges_view.is_some() {-            ptr::null()-        } else {-            edges_bytes.as_ptr()-        };+        // The escape index, escape rows and name tables live behind the+        // record array in the same payload, raw in both v6 and v7 — only the+        // record array itself is blocked-compressed. So the table base is the+        // payload base unconditionally; the per-record readers branch onto the+        // inflated view (see `edge_rec`). Nulling the base under v7 left every+        // table at `0x0 + offset` and the totals check below read past null+        // (on-device SIGSEGV in `OfflineRouter_init`, 2026-10-19).+        let edges_ptr = edges_bytes.as_ptr();         let escape_first = unsafe { edges_ptr.add(escape_first_off as usize) };         let escapes_ptr = unsafe { edges_ptr.add(escapes_off as usize) };         let names = EdgeBitmap {@@ -339,17 +347,20 @@ impl Graph {         };          // A wrong-length elevation payload is dropped, not kept mapped:-        // nothing should read a stale vintage's bytes.+        // nothing should read a stale vintage's bytes. A valid v7 blocked+        // view has a null raw pointer by design (`node_elevation` branches+        // onto the view first), so it must not count as "no elevation" here:+        // dropping the region would unmap the frames the view reads.         let mut own = own;-        if elevation.is_null() {+        if elevation.is_null() && elevation_view.is_none() {             own.elevation = None;         } -        let nodes = if nodes_view.is_some() {-            ptr::null()-        } else {-            nodes_bytes.as_ptr()-        };+        // Table base is the payload base unconditionally: under v7 the raw+        // bytes are the blocked section, never read as records (see `node`,+        // which branches onto the inflated view first). Nulling it instead+        // made `get_node`'s `is_null` guard return a zeroed node for every id.+        let nodes = nodes_bytes.as_ptr();         // --- Derived tables (identical formulas to the C++ init) ---         let mut lon_to_mm_scale = [0u32; 4096];         for (i, scale) in lon_to_mm_scale.iter_mut().enumerate() {
maps/src/main/rust/src/graph_part5.rs
diff --git a/maps/src/main/rust/src/graph_part5.rs b/maps/src/main/rust/src/graph_part5.rsindex ef71f079b7..57e619d0cf 100644--- a/maps/src/main/rust/src/graph_part5.rs+++ b/maps/src/main/rust/src/graph_part5.rs@@ -196,6 +196,59 @@ mod archive_tests {         ]     } +    /// One edge, v7 blocked: the escape index and name totals live behind the+    /// blocked records and must read through the payload base, not null.+    ///+    /// Regression for the on-device SIGSEGV (`OfflineRouter_init`, 2026-10-19):+    /// the v7 path nulled the edges/nodes base, so the escape-totals check in+    /// `assemble` read `0x0 + offset` and faulted. The zero-edge v7 test above+    /// takes the same code path, but with tables at offset 0 a null base still+    /// lands inside the first mapped page on some loaders — one non-empty edge+    /// record pushes the tables out and makes the fault deterministic.+    fn single_edge_payloads_v7() -> Vec<(u8, Vec<u8>, u64)> {+        // Two nodes (ids 0, 1) plus the sentinel: node 0 owns edge 0+        // (`edge_ptr` [0, 1, 1]; the sentinel is `edge_count`).+        let mut node_recs = Vec::new();+        for edge_ptr in [0u32, 1u32, 1u32] {+            node_recs.extend_from_slice(&0i32.to_le_bytes());+            node_recs.extend_from_slice(&0i32.to_le_bytes());+            node_recs.extend_from_slice(&edge_ptr.to_le_bytes());+        }+        let nodes = tilecodec::blocked::write_blocked(&node_recs, 12);+        // One 7-byte edge record: target_delta +1, dist 1000 mm, type 5, limit 50.+        let mut edge_rec = Vec::new();+        edge_rec.extend_from_slice(&1i16.to_le_bytes());+        edge_rec.extend_from_slice(&[0xE8, 0x03, 0x00]); // 1000, u24 LE+        edge_rec.push(5u8);+        edge_rec.push(50u8);+        let recs = tilecodec::blocked::write_blocked(&edge_rec, 7);+        let mut edges = recs;+        while edges.len() % 8 != 0 {+            edges.push(0);+        }+        // E = 1: two escape-block u32s (E/1024 + 1, total 0 escapes),+        // then the names bitmap (rank (1/512 + 1) = 2 u64s + present+        // div_ceil(1/8) = 1 byte), then zero name offsets (0 named).+        edges.extend_from_slice(&0u32.to_le_bytes());+        edges.extend_from_slice(&0u32.to_le_bytes());+        edges.extend_from_slice(&0u64.to_le_bytes());+        edges.extend_from_slice(&0u64.to_le_bytes());+        edges.push(0u8);+        vec![+            (+                ARCHIVE_KIND_GRAPH_META,+                meta_at(GRAPH_VERSION, 2, 1, 0, 0),+                0,+            ),+            (ARCHIVE_KIND_GRAPH_NODES, nodes, 1),+            (ARCHIVE_KIND_GRAPH_EDGES, edges, 0),+            // G = 0, E = 1: bitmap 17 + coarse 8 + within 2 + G 8 = 35 bytes+            // of trailer, zero blob. Sized from the counts, not copied from+            // the zero-edge fixture (26 bytes: its bitmap is 9 for E = 0).+            (ARCHIVE_KIND_GRAPH_INTERMEDIATE, vec![0u8; 35], 0),+        ]+    }+     #[test]     fn container_layers_parse_before_assemble_runs() {         let bytes = assemble(&minimal_payloads());@@ -227,6 +280,23 @@ mod archive_tests {         assert!(g.uses_blocked_sections(), "v7 takes the blocked path");     } +    #[test]+    fn a_v7_archive_with_an_edge_reads_the_tail_tables_past_the_records() {+        let g =+            load_slices(&single_edge_payloads_v7()).expect("a one-edge v7 archive loads");+        assert_eq!(g.node_count, 2);+        assert_eq!(g.edge_count, 1);+        assert_eq!(g.escape_count, 0);+        assert_eq!(g.named_edges, 0);+        // The record comes back through the inflate cache...+        let e = g.edge(0, 0);+        assert_eq!(e.target, 1, "target_delta +1 from node 0");+        assert_eq!(e.dist_mm, 1000);+        // ...and node 1's range covers the sentinel, which needs the real+        // nodes base, not null.+        assert_eq!(g.edge_range(1), (1, 1), "last node's range ends at edge_count");+    }+     #[test]     fn a_v7_nodes_payload_with_the_wrong_unpacked_length_is_refused() {         let mut payloads = minimal_payloads_v7();
metadata_data/photos/games-hub/7.png
diff --git a/metadata_data/photos/games-hub/7.png b/metadata_data/photos/games-hub/7.pngindex 04de5fb30d..b8ea2742c4 100644Binary files a/metadata_data/photos/games-hub/7.png and b/metadata_data/photos/games-hub/7.png differ
scripts/maps/build_graph.ps1
diff --git a/scripts/maps/build_graph.ps1 b/scripts/maps/build_graph.ps1index 5f364b736a..e80eddaf7d 100644--- a/scripts/maps/build_graph.ps1+++ b/scripts/maps/build_graph.ps1@@ -212,6 +212,25 @@ $Dem          = Join-Path $PSScriptRoot "inputs/world.mdem" $TransitManifest = Join-Path $PSScriptRoot "world_transit_work/feeds.manifest"  function Find-Built([string] $crate, [string] $name) {+    # The tool crates are root-workspace members (no [workspace] table), so+    # `cargo build` links into the WORKSPACE target dir (repo root+    # target/release), not the per-crate one. The per-crate target/ dirs are+    # fossils from when the crates were detached: cargo never refreshes them,+    # so resolving there silently runs an ancient binary (this exact failure+    # shipped a pre-fix tiler into a full archive build on 2026-10-19).+    # Prefer the workspace binary; fall back to the per-crate path only when+    # the workspace one is absent.+    $wsBuilt = Join-Path $PSScriptRoot "../../target/release/$name.exe"+    if (Test-Path $wsBuilt) {+        $wsItem = Get-Item $wsBuilt+        $crateItem = $null+        $cratePath = Join-Path $PSScriptRoot "$crate\target\release\$name.exe"+        if (Test-Path $cratePath) { $crateItem = Get-Item $cratePath }+        if ($null -eq $crateItem -or $wsItem.LastWriteTime -ge $crateItem.LastWriteTime) {+            return $wsItem.FullName+        }+        Write-Warning "$name.exe: per-crate copy ($($crateItem.LastWriteTime)) is newer than workspace copy ($($wsItem.LastWriteTime)); using per-crate copy"+    }     $built = Join-Path $PSScriptRoot "$crate\target\release\$name.exe"     if (-not (Test-Path $built)) {         throw "no $name.exe after building $crate -- this is a builder bug, not your input"
settings.gradle.kts
diff --git a/settings.gradle.kts b/settings.gradle.ktsindex 586f4128ca..88b4eba042 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -135,6 +135,9 @@ if (file("personal/amazon").exists()) { if (file("personal/kaiser").exists()) {     include(":personal:kaiser") }+if (file("personal/uniflix").exists()) {+    include(":personal:uniflix")+}  // Desktop JVM shells (Phase 2): host-side sync over the shared core. include(":desktop:notes")