AI-generated illustration

Image: AI-generated illustration

Why did Shelly’s background reads freeze, and what should a developer distinguish between the interim improvement and the proposed native path? [M]
In Shelly’s 2026-11-28 behavior, the improvement returned a stopped-bridge response; the permanent design proposed native reading paths to remove the React Native (RN) bridge dependency. [M]
Three questions frame the failure: what stopped in the background, how would each data source be read, and which operations still required a responding application? [M]

The failure: reading depended on the stopped bridge

On 2026-11-28, read_terminal_output, read_logs, and get_settings read through the RN bridge, which stopped when the Android application entered the background. [M]

Failure-chain condition Before the interim improvement After the interim improvement
Read request while the background bridge was stopped. [M] Responses could take as long as 100 seconds. [M] The request immediately returned “bridge stopped,” with measured responses of 137–154ms. [M]

The measured response identified the stopped-bridge condition; obtaining the requested data through native paths belonged to the permanent design. [M]

Application-handled operations had a separate execution limit in those measurements: operations such as service_control executed only while the application responded. [M]
When the application was unresponsive, those operations timed out without appearing in the audit record. [M]

The design: choose the read path by data source

The permanent design dated 2026-11-28 assigned terminal output and logcat to direct native reads, while application logs and settings would use an HMAC-signed path issued by RN. [M]

For the logcat part of that design, Android’s logging system consists of structured circular buffers maintained by the system process logd. [1]
Logcat dumps system messages, including messages written by an application through the Log class. [1]
The primary C/C++ interface to the logging system is the shared library liblog and its header android/log.h. [1]

Validate the background condition first

  • Establish an actual background transition. In React Native 0.84, AppState distinguishes active, meaning foreground operation, from background. [2]
    Android background conditions include another app, the home screen, and another Activity, including temporary system activities such as autofill credential pickers, even when launched by the application or the system. [2]

  • Separate loss of interaction from a state transition. Pulling down the Android notification drawer fires blur while AppState remains unchanged. [2]
    The focus event is received when the application gains focus and the user is interacting with it. [2]

  • Account for the launch-time state sample. AppState.currentState is null at launch while AppState retrieves its value over the bridge, and it is kept up to date afterward. [2]
    AppState.addEventListener accepts an event type and listener and returns an EventSubscription. [2]
    The change event calls its listener with one of the current application-state values when that state changes. [2]

Other native integration approaches

Asynchronous JavaScript-to-native calls

React Native’s legacy Android native-module integration lets JavaScript invoke Java/Kotlin methods annotated with @ReactMethod. [3]
Callbacks provide asynchronous data transfer from Java/Kotlin to JavaScript, and a native module can store a callback for later invocation, subject to the limit that a method invokes one callback, one time, choosing either success or failure. [3]

A Promise provides another asynchronous return shape: when a native method’s last parameter is a Promise, the corresponding JavaScript method returns a JS Promise object that supports async/await. [3]
The native method can resolve or reject that Promise at most once. [3]

Synchronous native calls

Setting isBlockingSynchronousMethod = true marks a native method as synchronous. [3]
Synchronous calls can have strong performance penalties and introduce threading-related bugs. [3]
For a required blocking call, React Native directs heavy work to an internally managed worker thread and callbacks from there. [3]

Validate the native entry point

  • Rebuild when the changed read implementation contains native code. React Native requires a native rebuild to expose native-code changes to JavaScript, whereas Metro can watch and rebuild JavaScript changes. [3]

  • Verify invocation at the method boundary. The Android native-module example places a Log.d message inside the method and confirms invocation by finding that message in ADB logs. [3]

  • Inspect registration when JavaScript must initiate the read. A native module must be added to a ReactPackage, and that package must be registered with React Native. [3]
    During initialization, React Native loops over the packages and registers their native modules. [3]

  • Review assumptions about the calling thread. React Native’s threading guidance says native modules should avoid such assumptions because the thread assignment is subject to change. [3]

Validate log visibility separately from invocation

  • Inspect compilation settings when the expected invocation message is absent. Depending on compilation settings, some logs may be completely removed from the binary, including Log.d calls removed through ProGuard configuration. [1]

  • Examine system properties when a tag’s expected severity is missing. For a tag named MyApp, liblog checks log.tag.MyApp, persist.log.tag.MyApp, log.tag, and persist.log.tag to determine the minimum severity sent to logd. [1]
    Those properties expect the first letter of the minimum severity: V, D, I, W, E, or S to disable all logs. [1]

  • Examine the application minimum when those properties are unset. In that condition, liblog uses the minimum priority set by __android_log_set_minimum_priority, whose default is INFO. [1]

  • Inspect display filtering when the expected tag is excluded from the output. A tag:priority expression selects messages for that tag at or above the specified priority. [1]
    Adding *:S makes the explicit tag filters an allowlist by setting all other tags to silent. [1]

  • Select the buffer containing the expected messages. The default buffer selection reports main, system, and crash, while -b requests alternate buffers. [1]
    The radio buffer contains radio/telephony messages, and events contains interpreted binary system event messages. [1]

  • Verify options on the target device before relying on them. Available logcat options depend on the device’s OS version, and many options are usable only as root. [1]
    The command adb logcat --help displays help specific to the device being used. [1]

  • Preserve the fields needed to inspect a request. The default threadtime format displays the date, invocation time, priority, tag, PID, and TID of the thread issuing each message. [1]
    The -v option selects an output format, with one output format permitted alongside applicable modifiers. [1]

Sources

AI disclosure: this post was researched, written and reviewed by AI tools.
Publishing: a post that passes automated checks may be published automatically, before the author reads it.