react-native: bugs: Attempt to invoke virtual method 'void com.facebook.react.uimanager.UlManagerModule.onBatchComplete()' on a null object reference

Description


import React from 'react';

import {StyleSheet, TextInput} from 'react-native';

function App(): React.JSX.Element {
  return <TextInput inputMode="text" style={styles.input} />;
}
const styles = StyleSheet.create({
  input: {
    flex: 1,
    height: 40,
    borderWidth: 1,
    borderColor: '#ddd',
    borderRadius: 8,
    paddingHorizontal: 8,
    marginHorizontal: 10,
  },
});

export default App;


Steps to reproduce

When TextInput appear, focus it, and then errors. image

React Native Version

0.73.2

adnroid

14

Affected Platforms

Runtime - Android

Output of npx react-native info

0 verbose cli /Users/chasen/.nvm/versions/node/v22.3.0/bin/node /Users/chasen/.nvm/versions/node/v22.3.0/lib/node_modules/npm/bin/npm-cli.js
1 info using npm@10.8.1
2 info using node@v22.3.0
3 silly config load:file:/Users/chasen/.nvm/versions/node/v22.3.0/lib/node_modules/npm/npmrc
4 silly config load:file:/Users/chasen/wangmin/xiangqu/.npmrc
5 silly config load:file:/Users/chasen/.npmrc
6 silly config load:file:/Users/chasen/.nvm/versions/node/v22.3.0/etc/npmrc
7 verbose title npm exec react info
8 verbose argv "exec" "--" "react" "info"
9 verbose logfile logs-max:10 dir:/Users/chasen/.npm/_logs/2024-11-18T12_07_41_756Z-
10 verbose logfile /Users/chasen/.npm/_logs/2024-11-18T12_07_41_756Z-debug-0.log
11 silly logfile start cleaning logs, removing 2 files
12 silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
13 silly logfile done cleaning log files
14 verbose shrinkwrap failed to load node_modules/.package-lock.json missing from lockfile: node_modules/rn-placeholder
15 verbose stack Error: could not determine executable to run
15 verbose stack     at getBinFromManifest (/Users/chasen/.nvm/versions/node/v22.3.0/lib/node_modules/npm/node_modules/libnpmexec/lib/get-bin-from-manifest.js:17:23)
15 verbose stack     at exec (/Users/chasen/.nvm/versions/node/v22.3.0/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js:198:15)
15 verbose stack     at async Npm.exec (/Users/chasen/.nvm/versions/node/v22.3.0/lib/node_modules/npm/lib/npm.js:207:9)
15 verbose stack     at async module.exports (/Users/chasen/.nvm/versions/node/v22.3.0/lib/node_modules/npm/lib/cli/entry.js:74:5)
16 verbose pkgid react@18.3.1
17 error could not determine executable to run
18 verbose cwd /Users/chasen/wangmin/xiangqu
19 verbose os Darwin 23.6.0
20 verbose node v22.3.0
21 verbose npm  v10.8.1
22 verbose exit 1
23 verbose code 1
24 error A complete log of this run can be found in: /Users/chasen/.npm/_logs/2024-11-18T12_07_41_756Z-debug-0.log

Stacktrace or Logs

Attempt to invoke virtual method 'voidcom.facebook.react.uimanager.UlManagerModule.onBatchComplete()' on a nullobject reference
run
RuntimeUtils.java:12
handleCallback
Handler.java:958
dispatchMessage
Handler.java:99
dispatchMessage
MessageQueueThreadHandler.java:27
loopOnce
Looperjava:257
loop
Looper.java:368
lambda$startNewBackgroundThread$2
MessageQueueThreadlmpl.java:217
run
D8$$SyntheticClass
run
Thread.java:1012

Reproducer

https://snack.expo.dev/WxSzNT5G5M9ff3hqMHZ35

Screenshots and Videos

image

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

I am getting this with 0.76.5 again

Same here getting the same error in 0.76.5

It happens when you using react-native-ui-lib or relevant 3rd libs. If yes, you can see below workaround to secure check using patch-package to modify the class RuntimeUtils in com.wix.reactnativeuilib.keyboardinput.utils then patch them:

Update the sUIUpdateClosure to this one:

// TODO Switch to GuardedRunnable when upgrading RN's minimal ver
// GuardedRunnable support for quite a long time, but it is safe to use after 0.60+
// So, it should be Runnable to safe check
```

private static final Runnable sUIUpdateClosure = () -> { try { UIManagerModule uiManager = ReactContextHolder.getContext() .getNativeModule(UIManagerModule.class); if (uiManager != null) { uiManager.onBatchComplete(); } } catch (Exception e) { e.printStackTrace(); } };

@Chasen-Zhang are you sure that this is happening on React Native 0.73.2?

I found that I used the UI library: https://github.com/wix/react-native-ui-lib When I remove it, The Errors gone! So you shoud check what libraries you have used.

I found that I used the UI library: wix/react-native-ui-lib When I remove it, The Errors gone! So you shoud check what libraries you have used.

Closing as per this

@Chasen-Zhang are you sure that this is happening on React Native 0.73.2?

I found that I used the UI library: https://github.com/wix/react-native-ui-lib When I remove it, The Errors gone! So you shoud check what libraries you have used.

Yes i narrowed it down after some digging found the error the library only supports react native 0.73 not 0.76