react-native-ui-lib
react-native-ui-lib copied to clipboard
Attempt to invoke virtual method 'void.com.facebook.react.uimanager.UIManagerModule.onBatchComplete()' on a null object reference
Description
Attempt to invoke virtual method 'void.com.facebook.react.uimanager.UIManagerModule.onBatchComplete()' on a null object reference
Related to
- [x] Components
- [ ] Demo
- [ ] Docs
- [ ] Typings
Steps to reproduce
Steps to reproduce the behavior:
- Create a new project with react-native": "^0.76"
- Setup react-native-ui-lib
- Add a TextField from react-native-ui-lib
- See error
Attempt to invoke virtual method 'void.com.facebook.react.uimanager.UIManagerModule.onBatchComplete()' on a null object reference
Expected behavior
For the app not to crash
Actual behavior
App crashes
More Info
Code snippet
<View flex paddingH-25 paddingT-120>
<Text blue50 text20>
Welcome
</Text>
<TextField text50 placeholder="username" grey10 />
<TextField text50 placeholder="password" secureTextEntry grey10 />
<View marginT-100 center>
<Button text70 white background-orange30 label="Login" />
<Button link text70 orange30 label="Sign Up" marginT-20 />
</View>
</View>
Screenshots/Video
Environment
System:
OS: Windows 11 10.0.26100
CPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900HK
Memory: 14.56 GB / 31.69 GB
Binaries:
Node:
version: 20.18.0
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 1.22.22
path: C:\Program Files\nodejs\yarn.CMD
npm:
version: 10.8.2
path: C:\Program Files\nodejs\npm.CMD
Watchman:
version: 20241103.093242.0
path: C:\ProgramData\chocolatey\bin\watchman.EXE
SDKs:
Android SDK:
API Levels:
- "34"
- "35"
Build Tools:
- 34.0.0
- 35.0.0
System Images:
- android-35 | Google Play Intel x86_64 Atom
Android NDK: Not Found
Windows SDK:
AllowDevelopmentWithoutDevLicense: Enabled
IDEs:
Android Studio: AI-242.23339.11.2421.12550806
Visual Studio: Not Found
Languages:
Java:
version: 17.0.13
path: /c/Program Files/Microsoft/jdk-17.0.13.11-hotspot/bin/javac
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.76.2
wanted: 0.76.2
react-native-windows: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
- React Native version: "0.76.2"
- React Native UI Lib version: "^7.34.2"
- "react-native-gesture-handler": "^2.21.2",
- "react-native-reanimated": "^3.16.1",
Affected platforms
- [x] Android
- [ ] iOS
- [ ] Web
Commenting out the following line in RuntimeUtils.java fixes the issue:
ReactContextHolder.getContext().getNativeModule(UIManagerModule.class).onBatchComplete();
Not sure what the long term solution is.
package com.wix.reactnativeuilib.keyboardinput.utils;
import com.facebook.react.uimanager.UIManagerModule;
import com.wix.reactnativeuilib.keyboardinput.ReactContextHolder;
public class RuntimeUtils {
// TODO Switch to GuardedRunnable when upgrading RN's minimal ver
private static final Runnable sUIUpdateClosure = new Runnable() {
@Override
public void run() {
ReactContextHolder.getContext().getNativeModule(UIManagerModule.class).onBatchComplete();
}
};
public static void runOnUIThread(Runnable runnable) {
if (ReactContextHolder.getContext() != null) {
ReactContextHolder.getContext().runOnUiQueueThread(runnable);
}
}
public static void dispatchUIUpdates(final Runnable userRunnable) {
runOnUIThread(new Runnable() {
@Override
public void run() {
userRunnable.run();
if (ReactContextHolder.getContext() != null) {
ReactContextHolder.getContext().runOnNativeModulesQueueThread(sUIUpdateClosure);
}
}
});
}
}
Hi @muzhaqi16 does it reproduce on project with RN 0.73 ?
still not fixed? 🙁
Waiting for this fix
Having the same error can anybody recommend a fix till they resolve the issue
@matice2 @JoseAIG @AhmedMaqbool
Does the issue reproduce on RN 0.73?
Currently we are supporting RN 0.73, we will try to check this issue.
@matice2 @JoseAIG @AhmedMaqbool Does the issue reproduce on RN
0.73? Currently we are supporting RN0.73, we will try to check this issue.
Okay this only works on 0.73 my project is using 0.76 any sort of timeline when you guys will start supporting 0.76
I am getting the same error kindly fix it. i am only using the Carousel component
Same problem
I have the same problem. I have this error when input field on focus, and when hide application, and come back i get this error
Same problem here for TextField. "react": "^18.3.1", "react-native": "0.76.6", "react-native-ui-lib": "^7.0.0",
Same issue. Please, when will this problem be fixed??
@matice2 @JoseAIG @AhmedMaqbool Does the issue reproduce on RN
0.73? Currently we are supporting RN0.73, we will try to check this issue.
So when will this issue be fixed for latest react-native: 0.76.6 ??
I needed to update sUIUpdateClosure at this paths:
node_modules/react-native-ui-lib/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java
and
/home/vito/GitHub/mobile-apps/apps/user-mobile/node_modules/uilib-native/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java
From this:
private static final Runnable sUIUpdateClosure = new Runnable() {
@Override
public void run() {
ReactContextHolder.getContext().getNativeModule(UIManagerModule.class).onBatchComplete();
}
};
To this:
private static final Runnable sUIUpdateClosure = new Runnable() {
@Override
public void run() {
try {
UIManagerModule uiManager = ReactContextHolder.getContext()
.getNativeModule(UIManagerModule.class);
if (uiManager != null) {
uiManager.onBatchComplete();
} else {
// Log the error or handle it accordingly
System.err.println("UIManagerModule is null, cannot call onBatchComplete");
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
And it works to me.
I need to add this to patch-package too
Any update on this? I have installed the lastest version 7.36.0 and still the issue persists.
Thanks!
As was already said (and is mentioned in the first paragraph of the repo's README) — this library only supports RN 0.73. They'll support 0.77 at some point (no timeline given)
Clarity aside, being over a year behind the official RN releases is a deal breaker for us, so we have to remove our dep on this lib
The fix I suggested earlier works great. No problem using with 0.77
On Sat, Feb 15, 2025 at 16:06 mihaibulic2 @.***> wrote:
As was already said — this library only supports RN 0.73. They'll support 0.77 at some point (no timeline given)
Personally, being over a year behind the official RN releases is a deal breaker, so I'm removing my dep on RN UI lib.
— Reply to this email directly, view it on GitHub https://github.com/wix/react-native-ui-lib/issues/3397#issuecomment-2661140239, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB53IRJTBUMYKPRA43M2YPL2P7B53AVCNFSM6AAAAABSDRUKGSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNRRGE2DAMRTHE . You are receiving this because you were mentioned.Message ID: @.***> [image: mihaibulic2]mihaibulic2 left a comment (wix/react-native-ui-lib#3397) https://github.com/wix/react-native-ui-lib/issues/3397#issuecomment-2661140239
As was already said — this library only supports RN 0.73. They'll support 0.77 at some point (no timeline given)
Personally, being over a year behind the official RN releases is a deal breaker, so I'm removing my dep on RN UI lib.
— Reply to this email directly, view it on GitHub https://github.com/wix/react-native-ui-lib/issues/3397#issuecomment-2661140239, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB53IRJTBUMYKPRA43M2YPL2P7B53AVCNFSM6AAAAABSDRUKGSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNRRGE2DAMRTHE . You are receiving this because you were mentioned.Message ID: @.***>
` diff --git a/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java b/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java index 95c5e8ea473c83e2b95a47b42945befe13e69de2..cddcab08cc6c00f49612b7db56f446c1605f84aa 100644 --- a/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +++ b/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java @@ -9,7 +9,10 @@ public class RuntimeUtils { private static final Runnable sUIUpdateClosure = new Runnable() { @Override public void run() {
-
ReactContextHolder.getContext().getNativeModule(UIManagerModule.class).onBatchComplete();
-
var nativeModule = ReactContextHolder.getContext().getNativeModule(UIManagerModule.class); -
if (nativeModule != null) { -
nativeModule.onBatchComplete(); -
};} }
`
i didcthis patch and still facing the smae issues
hey @deidine also patch uilib-native package. its dependency
@iwalker7 > hey @deidine also patch uilib-native package. its dependency what you mean can you explain pls
@iwalker7 > hey @deidine also patch uilib-native package. its dependency what you mean can you explain pls
check it out https://github.com/wix/react-native-ui-lib/issues/3397#issuecomment-2607309623
I applied the fix and used patch-package, but it still gives me the same error Rn: 0.77 expo: 0.52 react-native-ui-lib: ^7.37.2
@iwalker7 @vitoalmeida
I applied the fix and used patch-package, but it still gives me the same error Rn: 0.77 expo: 0.52 react-native-ui-lib: ^7.37.2
patch the uilib-native too.
I applied the patch, works great but now my Dialogs on Android don't work correctly. Anyone else have this issue?
I applied the patch, works great but now my Dialogs on Android don't work correctly. Anyone else have this issue?
What issue did you run into? I applied the patch to both react-native-ui-lib and uilib-native and it works perfectly fine, I tested with a RNUI Dialog.
For those who still have the bug after patching files, cleaning npm cache may help :
rm -rf node_modules
rm package-lock.json
npm cache clean --force
npm start -- --reset-cache
Still same issue
I tried the patch, but it's not working with 'react-native': '0.78.1' and 'react-native-ui-lib': '^7.39.1'.
The patch worked well in my environment.
expo: 52.0.42 react-native: 0.76.9 react-native-ui-lib: 7.39.0
As already mentioned, the patch needs to be applied not only to react-native-ui-lib but also to uilib-native. Just to be safe, I applied patches to both. The directory structure looks like this:
📁patches
┣ 📄react-native-ui-lib+7.39.0.patch
┗ 📄uilib-native+4.5.1.patch
"expo": "^53.0.9",
"react-native": "0.79.2",
"react-native-ui-lib": "^7.41.1",
Bug still there. Patch worked.