refactor(meshchat): update map to render tiles faster (online), message handling by adding context support to forwarding and delivery methods; improve LXMF message processing and router initialization
Some checks failed
CI / test-backend (push) Successful in 4s
CI / build-frontend (push) Successful in 1m54s
CI / test-lang (push) Successful in 1m53s
CI / test-backend (pull_request) Successful in 21s
Build and Publish Docker Image / build (pull_request) Has been skipped
CI / test-lang (pull_request) Successful in 49s
OSV-Scanner PR Scan / scan-pr (pull_request) Successful in 23s
CI / lint (push) Successful in 9m46s
CI / build-frontend (pull_request) Successful in 9m44s
CI / lint (pull_request) Successful in 9m47s
Build Test / Build and Test (pull_request) Successful in 13m17s
Benchmarks / benchmark (push) Successful in 14m34s
Benchmarks / benchmark (pull_request) Successful in 14m42s
Build and Publish Docker Image / build-dev (pull_request) Successful in 13m53s
Tests / test (push) Failing after 26m51s
Tests / test (pull_request) Failing after 24m53s
Build Test / Build and Test (push) Successful in 45m21s

This commit is contained in:
2026-01-04 19:10:22 -06:00
parent ff69de1346
commit 629bbbc7c6
5 changed files with 119 additions and 45 deletions

View File

@@ -1,10 +1,10 @@
import base64
import os
import LXMF
import RNS
from .database import Database
from .meshchat_utils import create_lxmf_router
class ForwardingManager:
@@ -34,7 +34,7 @@ class ForwardingManager:
)
os.makedirs(router_storage_path, exist_ok=True)
router = LXMF.LXMRouter(
router = create_lxmf_router(
identity=alias_identity,
storagepath=router_storage_path,
)
@@ -79,7 +79,7 @@ class ForwardingManager:
)
os.makedirs(router_storage_path, exist_ok=True)
router = LXMF.LXMRouter(
router = create_lxmf_router(
identity=alias_identity,
storagepath=router_storage_path,
)

View File

@@ -2,7 +2,6 @@ import os
import asyncio
import threading
import RNS
import LXMF
from meshchatx.src.backend.database import Database
from meshchatx.src.backend.integrity_manager import IntegrityManager
from meshchatx.src.backend.config_manager import ConfigManager
@@ -21,6 +20,7 @@ from meshchatx.src.backend.rnpath_handler import RNPathHandler
from meshchatx.src.backend.rnprobe_handler import RNProbeHandler
from meshchatx.src.backend.translator_handler import TranslatorHandler
from meshchatx.src.backend.forwarding_manager import ForwardingManager
from meshchatx.src.backend.meshchat_utils import create_lxmf_router
from meshchatx.src.backend.announce_handler import AnnounceHandler
from meshchatx.src.backend.community_interfaces import CommunityInterfacesManager
@@ -168,7 +168,7 @@ class IdentityContext:
# 4. Initialize LXMF Router
propagation_stamp_cost = self.config.lxmf_propagation_node_stamp_cost.get()
self.message_router = LXMF.LXMRouter(
self.message_router = create_lxmf_router(
identity=self.identity,
storagepath=self.lxmf_router_path,
propagation_cost=propagation_stamp_cost,

View File

@@ -1,11 +1,39 @@
import base64
import json
import signal
import threading
import LXMF
import RNS.vendor.umsgpack as msgpack
from LXMF import LXMRouter
def create_lxmf_router(identity, storagepath, propagation_cost=None):
"""
Creates an LXMF.LXMRouter instance safely, avoiding signal handler crashes
when called from non-main threads.
"""
if threading.current_thread() != threading.main_thread():
# signal.signal can only be called from the main thread in Python
# We monkeypatch it temporarily to avoid the ValueError
original_signal = signal.signal
try:
signal.signal = lambda s, h: None
return LXMF.LXMRouter(
identity=identity,
storagepath=storagepath,
propagation_cost=propagation_cost,
)
finally:
signal.signal = original_signal
else:
return LXMF.LXMRouter(
identity=identity,
storagepath=storagepath,
propagation_cost=propagation_cost,
)
def parse_bool_query_param(value: str | None) -> bool:
if value is None:
return False

View File

@@ -1520,7 +1520,10 @@ export default {
throw new Error(`HTTP ${response.status}`);
}
const blob = await response.blob();
tile.getImage().src = URL.createObjectURL(blob);
const url = URL.createObjectURL(blob);
tile.getImage().src = url;
// Cleanup to prevent memory leaks
setTimeout(() => URL.revokeObjectURL(url), 10000);
} catch {
tile.setState(3);
}
@@ -1535,7 +1538,9 @@ export default {
try {
const cached = await TileCache.getTile(src);
if (cached) {
tile.getImage().src = URL.createObjectURL(cached);
const url = URL.createObjectURL(cached);
tile.getImage().src = url;
setTimeout(() => URL.revokeObjectURL(url), 10000);
return;
}
@@ -1544,8 +1549,12 @@ export default {
throw new Error(`HTTP ${response.status}`);
}
const blob = await response.blob();
await TileCache.setTile(src, blob);
tile.getImage().src = URL.createObjectURL(blob);
const url = URL.createObjectURL(blob);
tile.getImage().src = url;
setTimeout(() => URL.revokeObjectURL(url), 10000);
// Background cache write to avoid blocking UI
TileCache.setTile(src, blob).catch(() => {});
} catch {
originalTileLoadFunction(tile, src);
}