# Android ART Debugging Fix with a Hook-Based Solution

A temporary library resolves JDWP deadlock issues, making debugging smoother.

- **Source:** [ProAndroidDev - Medium](https://brifing.si/source/d9553fa9-7b72-4b9b-bc73-c6bf9a40dd5f)
- **Published:** 2026-07-19
- **Topic:** [Software & Engineering](https://brifing.si/c/engineering)
- **Original article:** <https://proandroiddev.com/art-broke-our-debugging-so-we-fixed-it-with-a-hook-while-the-real-fix-rides-the-mainline-train-cfca56a0968b?source=rss----c72404660798---4>
- **On Brifing:** https://brifing.si/s/4d3991a9-a3e8-4479-8ddb-5484d1b0e01d

## ART Debugging Issue

On Android 16, attaching a Java debugger (JDWP) to large apps causes process lockups and ANR errors. This stems from a deadlock between the garbage collector thread and ART's native debug layer. While the ART team acknowledges the bug, a mainline fix will take time.

## Need for a Workaround

Developers need immediate debugging capabilities without waiting for the fix. Previous workarounds either altered the environment or hindered seamless debugging in monolithic apps. A new approach aims to solve the issue directly within ART.

## JdwpSilencer Library

This library uses a native hook to suppress JDWP events inside ART, preventing the deadlock window from opening. It allows developers to debug large apps effortlessly, with the debugger attaching smoothly as if nothing happened.

## Technical Details

The deadlock triggers when CLASS_PREPARE, THREAD_END/THREAD_START, and GC pressure overlap during debug attachment. JdwpSilencer reduces pressure by silencing ThreadStart and ThreadDeath events, which are only used for debugger bookkeeping and don’t affect app logic.

## Native Hook Implementation

The solution intercepts art::RuntimeCallbacks methods, replacing them with no-op functions. Using the ShadowHook library, inline hooks are applied to libart.so symbols. This silences ThreadStart and ThreadDeath events, eliminating deadlock risks.

## Class Preparation Challenge

Initially, ClassPrepare and ClassLoad events were also silenced, but this broke breakpoints on unprepared classes. The final version only suppresses ThreadStart and ThreadDeath for a safer solution.

## Kotlin API Design

JdwpSilencer.kt offers four core functions: init(), isInitialized(), enabled, and debugLogs. This API simplifies hook setup and management. The enabled parameter allows dynamic toggling of event suppression.

## Kill Switch Feature

Some developers faced debugger hangs at the first breakpoint. The enabled parameter can be set to false to disable suppression dynamically, providing flexibility for different scenarios.

## Library Benefits

JdwpSilencer enables debugging without altering app structure. Native code modifications resolve the issue without performance overhead. Developers can continue their work seamlessly until the mainline fix arrives.

## Limitations

The solution may not work perfectly in all cases. Silencing ClassPrepare/ClassLoad events could limit some debugger features, but ThreadStart/ThreadDeath suppression suffices for most scenarios.

## Next Steps

Until the ART team releases the main fix, JdwpSilencer serves as a lifeline for developers. Its open-source nature allows community-driven improvements and adaptations.

## Conclusion

JdwpSilencer provides a practical solution for Android developers to bypass deadlock issues. Integrating this library can save time and maintain productivity while awaiting the official fix.

## Sources covering this story

- https://proandroiddev.com/art-broke-our-debugging-so-we-fixed-it-with-a-hook-while-the-real-fix-rides-the-mainline-train-cfca56a0968b?source=rss----c72404660798---4 — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
