Log in or register to post comments

NPE on resume activity

March 18, 2013 - 6:34pm #1

Vuforia SDK Version: 2.0.30 -

Description with steps to reproduce: Unity project using Vuforia had activity paused in background.
Clicked app icon on home screen to bring to front.
Crashed immediately with following stack trace. Has only happened once so far.

java.lang.NullPointerException
at com.unity3d.player.e.c(Unknown Source)
at com.unity3d.player.UnityPlayer.g(Unknown Source)
at com.unity3d.player.UnityPlayer.windowFocusChanged(Unknown Source)
at com.qualcomm.QCARUnityPlayer.QCARPlayerSharedActivity.onWindowFocusChanged(QCARPlayerSharedActivity.java:350)
at com.qualcomm.QCARUnityPlayer.QCARPlayerNativeActivity.onWindowFocusChanged(QCARPlayerNativeActivity.java:77)
at mobi.aroha.cariana.ui.AbstractMainMenuScreenActivity.onWindowFocusChanged(AbstractMainMenuScreenActivity.java:1184)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onWindowFocusChanged(PhoneWindow.java:2638)
at android.view.View.dispatchWindowFocusChanged(View.java:7557)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:938)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3013)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method) -

Development OS (Mac OS X, Windows, Linux): Windows -

Mobile OS and Version: 4.1.1 Android -

Mobile Device Manufacturer and Model name: Samsung S3 -

Do the Vuforia Sample Applications show the same behavior?: No

NPE on resume activity

March 29, 2013 - 1:24am #4

Thanks for sharing the solution !

NPE on resume activity

March 29, 2013 - 1:07am #3

 

No I've only tried on S3. I think I found the problem which was basically the onWindowFocusChanged logic was getting called twice.

1. My own AbstractMainMenuScreenActivity extends QCARPlayerNativeActivity

2. AbstractMainMenuScreenActivity implements the onWindowFocusChanged method as:

@Override

public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
 
if (mUnityPlayer != null) {
mUnityPlayer.windowFocusChanged(hasFocus);
}
 
}
 
3. The above super.onWindowFocusChanged(hasFocus) line calls onWindowFocusChanged in the QCARPlayerNativeActivity parent class
 
4. Without the source code I can't tell 100% but I think somewhere up there in the hierarchy mUnityPlayer.windowFocusChanged(hasFocus) is being called so my method's extra call to the same method is likely the culprit.
 
5. My override implementation (2.) of onWindowFocusChanged() followed the same logic in the NativeActivity class that was generated by Unity when I exported my project to an Eclipse project.
 
6. The same kind of problem was happening to me with onResume() as well. I would get an NPE if I paused the activity and then tried to resume it.

 

 

 

NPE on resume activity

March 19, 2013 - 1:35am #2

Hi, thanks for reporting the issue;

I see this occurs on Samsung S3; have you tested it on other devices as well ?

 

Log in or register to post comments