Merge pull request #3125 from nrobi144/fix/desktop-log-noise

fix: address root causes of 6 runtime log noise issues
This commit is contained in:
Vitor Pamplona
2026-06-03 07:59:09 -04:00
committed by GitHub
6 changed files with 32 additions and 17 deletions
@@ -44,6 +44,9 @@ object CachedRobohash {
msg: String,
isLightTheme: Boolean,
): ImageVector {
// Guard: empty/blank keys produce meaningless robohash; use a fallback hex
val key = msg.ifBlank { "0000000000000000000000000000000000000000000000000000000000000000" }
// resets cache on theme change
if (cacheIsForLightTheme == null) {
cacheIsForLightTheme = isLightTheme
@@ -52,13 +55,13 @@ object CachedRobohash {
cache.evictAll()
}
cache[msg]?.let {
cache[key]?.let {
return it
}
val vector = assembler.build(msg, isLightTheme)
val vector = assembler.build(key, isLightTheme)
cache.put(msg, vector)
cache.put(key, vector)
return vector
}
@@ -106,13 +106,9 @@ class LocalRelayStore(
if (!_enabled.value || _writesDisabled.value) return
val s = store ?: return
writeBundler.invalidateList(event) { batch ->
try {
s.transaction {
batch.forEach { insert(it) }
}
} catch (e: Exception) {
Log.w("LocalRelayStore") { "Batch insert failed: ${e.message}" }
}
// batchInsert uses per-row savepoints — UNIQUE constraint
// violations skip that row instead of failing the whole batch
s.batchInsert(batch.toList())
}
}
@@ -115,7 +115,12 @@ object VlcjPlayerPool {
}
// Build factory args — add --plugin-path fallback if env var wasn't set
val factoryArgs = mutableListOf("--no-xlib")
val factoryArgs =
mutableListOf(
"--no-xlib",
"--avcodec-hw=none", // Disable VideoToolbox — avoids CVPN chroma failures on macOS
"--reset-plugins-cache", // Rebuild stale plugins cache on startup
)
if (!macOsDiscoverer.envVarSet) {
val pluginPath =
macOsDiscoverer.discoveredPluginPath
@@ -85,9 +85,20 @@ class RelayUrlNormalizer {
private fun norm(url: String) = NormalizedRelayUrl(Rfc3986.normalize(url))
@OptIn(ExperimentalContracts::class)
fun fix(url: String): String? {
fun fix(rawUrl: String): String? {
if (rawUrl.length < 4) return null
if (rawUrl.contains("%00")) return null
// Trim trailing %20 (percent-encoded spaces from malformed event data)
val url =
rawUrl.trimEnd('%', '2', '0').let { trimmed ->
// Only accept if we actually removed a trailing %20 pattern
if (trimmed.length < rawUrl.length && rawUrl.endsWith("%20")) trimmed else rawUrl
}
if (url.length < 4) return null
if (url.contains("%00") || url.contains("%20")) return null
// Reject URLs with %20 in the middle — these are garbage
if (url.contains("%20")) return null
if (url.length > 50) {
// removes multiple urls in the same line
@@ -78,7 +78,7 @@ object Nip19Parser {
return type!! + key
} catch (e: Throwable) {
Log.e("NIP19 Parser") { "Issue trying to Decode NIP19 $uri: ${e.message}" }
Log.d("NIP19 Parser") { "Issue trying to Decode NIP19 $uri: ${e.message}" }
}
return null
@@ -98,7 +98,7 @@ object Nip19Parser {
return parseComponents(type, key, additionalChars?.ifEmpty { null })
} catch (e: Throwable) {
Log.e("NIP19 Parser") { "Issue trying to Decode NIP19 $uri: ${e.message}" }
Log.d("NIP19 Parser") { "Issue trying to Decode NIP19 $uri: ${e.message}" }
}
return null
@@ -127,7 +127,7 @@ object Nip19Parser {
ParseReturn(it, nip19, additionalChars)
}
} catch (e: Throwable) {
Log.w("NIP19 Parser") { "Issue trying to Decode NIP19 $key: ${e.message}" }
Log.d("NIP19 Parser") { "Issue trying to Decode NIP19 $key: ${e.message}" }
null
}
@@ -85,7 +85,7 @@ open class GiftWrapEvent(
try {
unwrapThrowing(signer)
} catch (_: Exception) {
Log.w("GiftWrapEvent", "Couldn't Decrypt the content " + this.toNostrUri())
Log.d("GiftWrapEvent") { "Couldn't Decrypt the content " + this.toNostrUri() }
null
}