Search Issue Tracker
By Design
Votes
1
Found in
2021.3.32f1
2022.3.12f1
2023.1.19f1
2023.2.0b16
2023.3.0a13
Issue ID
UUM-55633
Regression
No
[Android] The AndroidJavaObject.GetRawClass() method returns different pointer values when the same Java class is used
Reproduction steps:
1. Open the attached project “JavaProject”
2. Build And Run on Android
3. Observe the app
Expected result: The pointers are equal
Actual result: The pointers are different
Reproducible with: 2021.3.32f1, 2022.3.12f1, 2023.1.19f1, 2023.2.0b16, 2023.3.0a13
Reproducible with these devices:
VLNQA00518 - Google Pixel 4 (Pixel 4), CPU: Snapdragon 855 SM8150, GPU: Adreno 640, OS: 12
VLNQA00414 - Galaxy Note10+ 5G (SM-N976V), CPU: Snapdragon 855 SM8150, GPU: Adreno 640, OS: 9
VLNQA00278 - Xiaomi Redmi Note 7 (Redmi Note 7), CPU: Snapdragon 660, GPU: Adreno 512, OS: 9.0.0
VLNQA00139 - Vivo Xplay6 (vivo Xplay6), CPU: Snapdragon 820 MSM8996, GPU: Adreno 530, OS: 7.1.1
VLNQA00132 - Xiaomi Mi 5s (MI 5s), CPU: Snapdragon 820 MSM8996, GPU: Adreno 530, OS: 6.0.1
Motorola Edge 30 Android 12 (user’s info)
Testing environment: macOS(Intel) 14.0 Sonoma
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- “Remove Unused Overrides” available on not loaded Scene and throws “ArgumentException: The scene is not loaded” warning
- Adaptive Probe Volume occlusion edge is calculated incorrectly when viewing probes near geometry edges
- Sampling a texture using an HLSL file throws shader errors and the code does not compile
- "Graphics.CopyTexture called with null source texture" error when Base Camera of an Overlay Camera is removed with DX11 Graphics API and Compatibility Mode enabled
- WebGL sends wrong value with large numbers when SendMessage function is used
Resolution Note:
Hello.
When I tested it, I could see the results below. And this is expected.
2023/12/12 16:00:11.253 12063 14456 Info Unity AndroidJNI.IsSameObject(firstObject.GetRawClass()[12246], secondObject.GetRawClass()[12362]) = True
2023/12/12 16:00:11.253 12063 14456 Info Unity AndroidJNI.IsSameObject(firstObject.GetRawObject():[12378], secondObject.GetRawObject():[12406]) = False
2023/12/12 16:00:11.254 12063 14456 Info Unity AndroidJNI.IsSameObject(firstClass.GetRawObject():[0], secondClass.GetRawObject():[0]) = True
2023/12/12 16:00:11.254 12063 14456 Info Unity AndroidJNI.IsSameObject(firstClass.GetRawClass():[12422], secondClass.GetRawClass():[12438]) = True
I am not sure if this link(https://developer.android.com/training/articles/perf-jni) might be helpful or not. You can find the following text in the link:
--------------
All JNI methods accept both local and global references as arguments. It's possible for references to the same object to have different values. For example, the return values from consecutive calls to NewGlobalRef on the same object may be different. To see if two references refer to the same object, you must use the IsSameObject function. Never compare references with == in native code.
--------------
Therefore, the returns of GetRawClass() may be different, even though it points to the same class, and you should use IsSameObject to compare.