Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
"allow": [
"Bash(grep -r \"\\\\.FLATPAK\\\\|Flatpak\\\\|flatpak\" . --include=*.kt)",
"Bash(./gradlew *)",
"Bash(rtk find *)"
"Bash(rtk find *)",
"WebSearch",
"WebFetch(domain:github.com)",
"WebFetch(domain:www.jetbrains.com)",
"WebFetch(domain:youtrack.jetbrains.com)",
"WebFetch(domain:raw.githubusercontent.com)",
"WebFetch(domain:blog.jetbrains.com)"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package zed.rainxch.githubstore

import java.awt.AWTEvent
import java.awt.EventQueue
import java.awt.Toolkit
import java.util.concurrent.atomic.AtomicBoolean

/**
* Workaround for a Compose Multiplatform 1.10.x NPE on macOS where the native
* AX bridge (`sun.lwawt.macosx.CAccessible$AXChangeNotifier`) queries a
* Compose semantic node that has already been removed by Compose's own
* accessibility sync loop. The stack trace fingerprint is:
*
* androidx.compose.ui.platform.a11y.SemanticsOwnerAccessibility.accessibleParentOf
* -> sun.lwawt.macosx.CAccessible$AXChangeNotifier.propertyChange
*
* The uncaught exception poisons the AWT EventDispatchThread and the app
* appears to freeze/crash on click. Installing a filtering [EventQueue]
* swallows only that specific NPE so the EDT keeps draining events.
* Trade-off: macOS VoiceOver may miss updates on those removed nodes.
* Remove once the upstream fix lands (track against Compose MP 1.11+).
*
* See [GitHub-Store#330](https://github.com/OpenHub-Store/GitHub-Store/issues/330).
*/
object A11yCrashGuard {
fun install() {
val osName = System.getProperty("os.name")?.lowercase().orEmpty()
if (!osName.contains("mac")) return
Toolkit.getDefaultToolkit().systemEventQueue.push(FilteringEventQueue())
}
Comment on lines +26 to +30
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

install() is not idempotent.

Every call pushes another FilteringEventQueue on top of the current system event queue. If startup ever invokes this twice (tests, hot-reload, restart paths), you'll stack filtering queues and each event will traverse multiple dispatchEvent frames. Consider guarding with an AtomicBoolean so subsequent calls are no-ops.

Proposed fix
 object A11yCrashGuard {
+    private val installed = java.util.concurrent.atomic.AtomicBoolean(false)
+
     fun install() {
         val osName = System.getProperty("os.name")?.lowercase().orEmpty()
         if (!osName.contains("mac")) return
+        if (!installed.compareAndSet(false, true)) return
         Toolkit.getDefaultToolkit().systemEventQueue.push(FilteringEventQueue())
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/A11yCrashGuard.kt`
around lines 26 - 30, install() currently pushes a new FilteringEventQueue every
call which stacks handlers; make it idempotent by adding a private AtomicBoolean
(e.g., "installed") checked at the start of install(): if already true return,
otherwise set it to true and proceed to push the FilteringEventQueue; reference
the existing install() function and the FilteringEventQueue class so future
calls become no-ops and avoid stacking multiple event queues.


private class FilteringEventQueue : EventQueue() {
private val warned = AtomicBoolean(false)

override fun dispatchEvent(event: AWTEvent) {
try {
super.dispatchEvent(event)
} catch (npe: NullPointerException) {
if (isComposeA11yNpe(npe)) {
if (warned.compareAndSet(false, true)) {
System.err.println(
"[A11yCrashGuard] Suppressed Compose a11y NPE on macOS " +
"(known issue, see GitHub-Store#330). Further occurrences silenced.",
)
}
return
}
throw npe
}
}

private fun isComposeA11yNpe(throwable: Throwable): Boolean {
var current: Throwable? = throwable
while (current != null) {
if (current.stackTrace.any { frame ->
frame.className.startsWith("androidx.compose.ui.platform.a11y")
}
) {
return true
}
current = current.cause
}
return false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ fun main(args: Array<String>) {
// `CrashReporter.resolveLogDir` for the per-OS path).
CrashReporter.install()

// Guard the AWT EventDispatchThread against a known Compose MP 1.10.x NPE
// raised by the macOS accessibility bridge (see `A11yCrashGuard`).
A11yCrashGuard.install()

// Reduce JVM DNS cache TTL so network changes (VPN on/off) are picked up quickly.
// Default JVM caches positive lookups for 30s and negative lookups forever,
// which breaks connectivity when a VPN changes DNS/routing mid-session.
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ androidTools = "32.0.1"

# Compose
compose-hot-reload = "1.0.0"
compose-multiplatform = "1.10.1"
compose-multiplatform = "1.10.3"
compose-lifecycle = "2.9.6"
navigation-compose = "2.9.2"
jetbrains-core-bundle = "1.0.1"
Expand All @@ -33,7 +33,7 @@ room = "2.8.4"
slf4jSimple = "2.0.17"
sqlite = "2.6.2"
datastore = "1.2.0"
compose-jetbrains = "1.10.1"
compose-jetbrains = "1.10.3"
compose-jetbrains-material-you = "1.11.0-alpha03"
jetbrains-savedstate = "1.4.0"
moko = "0.20.1"
Expand All @@ -45,7 +45,7 @@ shizuku = "13.1.5"
hidden-api = "4.4.0"
jsystemthemedetector = "3.9.1"
work = "2.11.1"
resources="1.10.1"
resources="1.10.3"

ktlint-gradle = "12.1.1"
flatpak-gradle-generator = "1.7.0"
Expand Down