react-native-unity
react-native-unity copied to clipboard
unity crash with addUnityViewToGroup
Hello.
Thank you for your great work. I've build your example successfully. but It's crashed. unity load is successfully load at first. but almost next load was crashed.
https://user-images.githubusercontent.com/22703602/167987171-13875d0e-8b25-4625-bc25-299569d4e7b9.mp4
2022-05-12 12:38:19.515 5764-5764/com.example E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example, PID: 5764
java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Version '2021.3.2f1 (d6360bedb9a0)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'armeabi-v7a'
Build fingerprint: 'samsung/z3qksx/z3q:12/SP1A.210812.016/G988NKSU1GVC7:user/release-keys'
Revision: '15'
ABI: 'arm'
Timestamp: 2022-05-12 12:38:15+0900
pid: 5764, tid: 7694, name: UnityGfxDeviceW >>> com.example <<<
uid: 10041
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
Cause: null pointer dereference
r0 ad24a330 r1 00000008 r2 00000087 r3 00000000
r4 ace17b70 r5 00000040 r6 ace112c0 r7 ae28e150
r8 ad24a330 r9 ffffffff r10 ace2e200 r11 00000001
ip 00000000 sp a5e6be80 lr af9c6278 pc af9c729c
backtrace:
#00 pc 0041829c /data/app/~~VQI66LEWJupqVrg2ybOXWw==/com.example-ruYKx-EqLVTGo54fpqT4YQ==/lib/arm/libunity.so (BuildId: 9faa1e7e16a9e71bb4a70ee16bbc3bad4e940f05)
#01 pc 00429608 /data/app/~~VQI66LEWJupqVrg2ybOXWw==/com.example-ruYKx-EqLVTGo54fpqT4YQ==/lib/arm/libunity.so (BuildId: 9faa1e7e16a9e71bb4a70ee16bbc3bad4e940f05)
#02 pc 0040969c /data/app/~~VQI66LEWJupqVrg2ybOXWw==/com.example-ruYKx-EqLVTGo54fpqT4YQ==/lib/arm/libunity.so (BuildId: 9faa1e7e16a9e71bb4a70ee16bbc3bad4e940f05)
#03 pc 00403f20 /data/app/~~VQI66LEWJupqVrg2ybOXWw==/com.example-ruYKx-EqLVTGo54fpqT4YQ==/lib/arm/libunity.so (BuildId: 9faa1e7e16a9e71bb4a70ee16bbc3bad4e940f05)
#04 pc 00403da0 /data/app/~~VQI66LEWJupqVrg2ybOXWw==/com.example-ruYKx-EqLVTGo54fpqT4YQ==/lib/arm/libunity.so (BuildId: 9faa1e7e16a9e71bb4a70ee16bbc3bad4e940f05)
#05 pc 0049a593 /data/app/~~VQI66LEWJupqVrg2ybOXWw==/com.example-ruYKx-EqLVTGo54fpqT4YQ==/lib/arm/libunity.so (BuildId: 9faa1e7e16a9e71bb4a70ee16bbc3bad4e940f05)
#06 pc 004a096f /data/app/~~VQI66LEWJupqVrg2ybOXWw==/com.example-ruYKx-EqLVTGo54fpqT4YQ==/lib/arm/libunity.so (BuildId: 9faa1e7e16a9e71bb4a70ee16bbc3bad4e940f05)
#07 pc 0049a097 /data/app/~~VQI66LEWJupqVrg2ybOXWw==/com.example-ruYKx-EqLVTGo54fpqT4YQ==/lib/arm/libunity.so (BuildId: 9faa1e7e16a9e71bb4a70ee16bbc3bad4e940f05)
#08 pc 00161c8b /data/app/~~VQI66LEWJupqVrg2ybOXWw==/com.example-ruYKx-EqLVTGo54fpqT4YQ==/lib/arm/libunity.so (BuildId: 9faa1e7e16a9e71bb4a70ee16bbc3bad4e940f05)
#09 pc 000802e7 /apex/com.android.runtime/lib/bionic/libc.so (pthread_attr_destroy+6) (BuildId: 5fd652727ca3edbb2b9609b35cb5811f)
at libunity.0x41829c(Native Method)
at libunity.0x429608(Native Method)
at libunity.0x40969c(Native Method)
at libunity.0x403f20(Native Method)
at libunity.0x403da0(Native Method)
at libunity.0x49a593(Native Method)
at libunity.0x4a096f(Native Method)
at libunity.0x49a097(Native Method)
at libunity.0x161c8b(Native Method)
at libc.pthread_attr_destroy(pthread_attr_destroy:6)
I found error line.
// ReactNativeUnity.java
...
public static void addUnityViwToGroup(ViewGroup group) {
if (unityPlayer == null) {
return;
}
if (unityPlayer.getParent() != null) {
((ViewGroup) unityPlayer.getParent()).removeView(unityPlayer);
}
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT);
group.addView(unityPlayer, 0, layoutParams);
unityPlayer.windowFocusChanged(true);
unityPlayer.requestFocus();
unityPlayer.resume(); // < -- here
}
...
It was load successfully when I remove the line.
+------- I was known it load successfully. but it was unloaded state.
@soronto3603 Did you find a fix for the crash on second load?
**Edit: Ignore this, the fix didn't work for me either, I'm still stuck.
Have you submitted a PR for this or closing this issue because the fix is to comment out the line you pointed out at the bottom. I wasted hours of my day trying to look into this issue to realise you already said what fixed it.
I am facing the same issue. I am using a Mac M1.
Is there a solution except commenting out unityPlayer.resume(); ?
When I commented out resume() it doesn't crash but the game is frozen.
It seems that it doesn't happen using the example project.
Maybe it's a matter of our different navigation lib. I am using react-native-navigation.
In addition, I 'd like to note that after the first unity load I can see the android status bar switches to white:
Before unity load
After unity load (while on unity screen)
After unity has been loaded once and then I return to Main screen
Hello @entelostre. I couldn't find any solution.
Hey @soronto3603 thanks for your interest. So you mean you get the same result as me (frozen player on second load) after commenting out that resume() call?