Add a resource-usage monitor to debug app; fix excessive memory-usage from screen preview when not focused

This commit is contained in:
James Babcock committed 2026-08-07 02:21:24 -07:00
1 parent b5213170e3
commit 9ade3503a0
6 files changed
+331 -7

No files matched your search

+10 -1
View File
@@ -1,4 +1,4 @@
import { ImageSource } from "@nativescript/core";
import { Application, ImageSource } from "@nativescript/core";
import { EvenAIStatus, EvenAIStatusName, EventSourceType, EventSourceTypeName, OsEventTypeList, OsEventTypeName } from "./events";
import { loadDeviceAddresses } from "./device-addresses";
import { ensureBlePermissions, ensureVoicePermissions } from "./android-permissions";
@@ -1703,6 +1703,15 @@ class DashboardController {
*/
private updateCompositePreview(): void {
if (!this.communicator) return;
// The connected foreground service intentionally keeps this controller
// alive after the phone UI is backgrounded. Do not keep constructing
// 640x480 Android Bitmaps for a window that cannot display them: besides
// being wasted work, paused NativeScript views can retain queued image
// updates long enough to put severe pressure on the native heap.
if (global.isAndroid) {
const activity = Application.android.foregroundActivity;
if (!activity || !activity.hasWindowFocus()) return;
}
const now = Date.now();
if (
this.lastConnectedPreviewUpdateAtMs > 0 &&