Skip to content

Android crash in Google automated tests: onAccessibilityStateChanged: Cannot read properties of null (reading 'set') #11049

@pichurichko

Description

@pichurichko

Issue Description

We’re seeing an Android crash that we can reproduce only in Google Play Console automated testing / pre-launch reports (x86 virtual device). We can’t reproduce it locally on physical devices/emulators, but the stack trace consistently points to the accessibility callback path and the fix below stops it in Google tests.

Exception com.tns.NativeScriptException: Calling js method onAccessibilityStateChanged failed
TypeError: Cannot read properties of null (reading 'set')
  at com.tns.Runtime.callJSMethodNative
  at com.tns.Runtime.dispatchCallJSMethodNative (Runtime.java:1384)
  at com.tns.Runtime.callJSMethodImpl (Runtime.java:1270)
  at com.tns.Runtime.callJSMethod (Runtime.java:1257)
  at com.tns.Runtime.callJSMethod (Runtime.java:1235)
  at com.tns.Runtime.callJSMethod (Runtime.java:1231)
  at com.tns.gen.android.view.accessibility.AccessibilityManager_AccessibilityStateChangeListener.onAccessibilityStateChanged (AccessibilityManager_AccessibilityStateChangeListener.java:19)
  at android.view.accessibility.AccessibilityManager.lambda$notifyAccessibilityStateChanged$0 (AccessibilityManager.java:1710)
  at android.view.accessibility.AccessibilityManager$$ExternalSyntheticLambda0.run (Unknown Source:4)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:201)
  at android.os.Looper.loop (Looper.java:288)
  at android.app.ActivityThread.main (ActivityThread.java:7870)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)

Suspected root cause in NativeScript core
application.android.ts

updateAccessibilityState() calls:

sharedA11YObservable.set(...)

but sharedA11YObservable can be undefined.

After applying this patch to updateAccessibilityState function, the crash stopped appearing in Google automated testing:

    if (!sharedA11YObservable) {
        return;
    }
function updateAccessibilityState() {
    if (!sharedA11YObservable) {
        return;
    }
    const accessibilityManager = getAndroidAccessibilityManager();
    if (!accessibilityManager) {
        sharedA11YObservable.set(accessibilityStateEnabledPropName, false);
        sharedA11YObservable.set(touchExplorationStateEnabledPropName, false);
        return;
    }
    sharedA11YObservable.set(accessibilityStateEnabledPropName, !!accessibilityManager.isEnabled());
    sharedA11YObservable.set(touchExplorationStateEnabledPropName, !!accessibilityManager.isTouchExplorationEnabled());
}

Reproduction

We cannot reproduce this crash manually.
It appears only in Google Play automated testing / pre-launch reports on an x86 virtual device.

Relevant log output (if applicable)

Environment

OS: macOS 26.2
CPU: (16) arm64 Apple M4 Max
Shell: /bin/zsh
node: 25.1.0
npm: 11.6.2
nativescript: 9.0.1

# android
java: 17.0.17
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found

# ios
xcode: 26.0.1/17A400
cocoapods: 1.16.2
python: Not Found
python3: 3.9.6
ruby: 3.3.10
platforms: 
  - DriverKit 25.0
  - iOS 26.0
  - macOS 26.0
  - tvOS 26.0
  - visionOS 26.0
  - watchOS 26.0

Dependencies

"devDependencies": {
  "@angular-devkit/build-angular": "~16.2.0",
  "@angular/compiler-cli": "~16.2.0",
  "@nativescript/android": "9.0.2",
  "@nativescript/ios": "9.0.2",
  "@nativescript/types": "9.0.0",
  "@nativescript/webpack": "5.0.29",
  "@ngtools/webpack": "~16.2.0",
  "@types/url-parse": "^1.4.11",
  "process": "^0.11.10",
  "typescript": "5.1.6",
  "util": "^0.12.5"
}

Please accept these terms

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-pending-triageReported bug, pending triage to confirm.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions