Files
NavFrame/docs/TFT_DIAGNOSTICS.md
T

34 lines
5.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Persistent TFT map diagnostics
Starting with NavFrame 0.13.2, map-render failures and the first successful render after a failure are saved automatically on the phone. The history does not depend on Logcat or on keeping the service alive. Completed writes are retained across app/service restarts and a phone reboot, including a shutdown caused by an empty battery.
## Export after an incident
When stationary, open **Menu → Information and licenses → TFT map diagnosis → Share**. In the Spanish UI this is **☰ → Información y licencias → Diagnóstico del mapa TFT → Compartir**.
The shared text includes the current service diagnostic, when available, and the saved history. History remains available when no service is bound. Save it before reinstalling the app or clearing app data. **Clear history** removes saved events after confirmation; it does not stop navigation or erase the current in-memory service diagnostic.
## Recorded information
Each event contains its UTC timestamp, app version, Android API level, MapLibre version, failure/recovery type, failure category and render stage, classified resource/reason and HTTP error status if available, render duration, retry delay/backoff attempt, active source type (`LOCAL` or `ONLINE`), observed connectivity, navigation mode/status, and TFT connection state.
The backoff attempt is capped at four, like the renderer's existing retry policy. Repeated failures continue to create separate timestamped records after that limit. Only the first successful render following failures creates a recovery record; normal successful frames are not logged.
From 0.13.6, diagnostics also retain the callback/exception class, a bounded sequence of allowlisted SDK diagnostic words (`WORDS_...`), screen interactive state, low-memory status and available system memory. Render stages distinguish camera updates, route GeoJSON updates and snapshot requests; native snapshot failure callbacks carry `SnapshotterErrorCallback` rather than the generic `SDK_CALLBACK`. URL/path/quoted payloads are removed before extracting known diagnostic words. An empty callback is distinguished from an unclassified nonempty message. This exposes messages such as snapshot/failed/no/tile/data without copying arbitrary SDK text. These fields are evidence, not proof that memory or screen state caused the failure.
Raw SDK messages, stack traces, URLs, tokens, coordinates, route geometry, destinations, search text, and Bluetooth identifiers are excluded. The history contains fixed labels and numbers, not a copy of Logcat. Network state is diagnostic context: a disconnected network does not itself explain a failure of a selected local map.
## Storage and limits
The history is a private app file named `tft-map-diagnostics.json` in Android's `noBackupFilesDir`. No storage permission is required; the app does not upload it automatically, and it is excluded from backup/device transfer. The file retains up to 100 failure/recovery records and is bounded at 128 KiB. Starting with 0.13.6, consecutive identical failures at the maximum retry backoff are grouped into one record with an occurrence count and first/last UTC timestamps. Initial retries and recovery records remain separate; the aggregate shows the latest navigation, network and TFT states. Changes in error classification, source, mode or app version start a new record. This prevents a long stream of identical failures from immediately erasing its onset. Older records are discarded when the limit is reached. Existing 0.13.2–0.13.5 files remain readable; previously evicted events cannot be recovered.
File operations run on an IO dispatcher. Writes are synced and replaced atomically, so an interrupted replacement preserves the previous completed history. A failure that occurs while a shutdown interrupts its write may not be retained. Clearing app data or uninstalling NavFrame deletes the history.
If reading fails, the diagnostic dialog reports that the history is unavailable and never exports the unreadable file as text. The next record replaces an unreadable history with a valid event. If storage cannot be written, navigation/error-frame handling continues; the current service diagnostic and Logcat report `TFT_MAP_HISTORY_WRITE_FAILED`.
## What this cannot recover
Events from before installing 0.13.2 cannot be reconstructed. This is a record of failures handled by NavFrame's TFT rendering path, not a system-wide crash recorder: abrupt native process crashes and power loss before a failure is recorded may leave no new event. A recovery record means image generation succeeded, not that delivery to the physical TFT was verified. The history helps investigate incidents; it does not establish their root cause by itself.
Tests cover reopening persisted events, retention, interrupted replacement, malformed/oversized input, unavailable storage, service failure followed by recovery/recreation, and sharing/clearing saved history without a bound service. Physical power-loss behavior and MapLibre OpenGL/TFT rendering still need device validation.