Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by AltairHVS · Sep 20, 2016 at 01:42 PM · androidfocuskillprocesspausing

Simple Android project shuts down when user presses the Recent Apps button

The game shuts down when the user presses the Recent Apps button or changes focus to another app. I created a blank minimal project (attached) to see if it was the game code that was causing it but it does the same thing. I'm assuming that there is something I need to add to the Android manifest, but so far nothing I have found has fixed the issue. I have tried android:alwaysRetainTaskState="true" and android:clearTaskOnLaunch="false"

The memory use on the test project is minimal so it can't be being killed to release memory. Any ideas on how to fix this?


Test App

AndroidFocusTest

A new Unity project that contains no additional assets other than a test script. There is a text element in the center of the screen that is managed by the script which changes it based on app state and slowly rotates it so you can see that it is still running. The background color changes based on state so it can be seen even when the message is covered.


Behavior
All tests done with the debugger attached.

  • The app can lose and gain focus via the notification bar with no issues.

  • The app survives when locking and unlocking the phone even over extended periods.

  • About one second after the user presses the Recent Apps or Home button the game is terminated and the debugger is disconnected. A breakpoint set on OnApplicationPause does get hit, but then the debugger closes.


Notable Output

 18.890  1347  4861 D     ActivityManager: mDVFSHelper.acquire()
 18.900  1347  4861 D     InputDispatcher: Focused application set to: xxxx
 18.900  1347  4861 D     InputDispatcher: Focus left window: 9097
 ...
 18.980  9097  9097 V     ActivityThread: updateVisibility : ActivityRecord{2dcddff token=android.os.BinderProxy@1aec36c {com.unityandroidtest.focus/com.unity3d.player.UnityPlayerActivity}} show : false
 18.980  2368  2368 D     SecWifiDisplayUtil: Metadata value : SecSettings2
 18.990  1347  1357 I     art     : Background partial concurrent mark sweep GC freed 47183(2MB) AllocSpace objects, 4(80KB) LOS objects, 25% free, 46MB/62MB, paused 1.648ms total 117.852ms
 18.990  1347  1502 D     ActivityManager: post active user change for 0 fullscreen true isFloatingActivity() false isHomeActivity() false
 18.990  1347  1502 D     KnoxTimeoutHandler: postActiveUserChange [MsgParam] userId: 0 fullscreen is true showWhenlocked is false
 18.990   971  1476 V     audio_hw_primary: out_get_latency: Latency 80
 18.990  2368  2368 D     ScoverManager: unregisterListener
 18.990  1347  1347 D     KnoxTimeoutHandler: handleActiveUserChange [MsgParam] userId: 0 fullscreen is true showWhenlocked is false
 18.990  1347  2470 D     CoverManagerWhiteLists: isAllowedToUse : SIGNATURE_MATCH
 18.990  1347  2723 D     CoverManagerWhiteLists: isAllowedToUse : SIGNATURE_MATCH
 18.990  1347  2723 D     CoverManager.StateNotifier: unregisterCallback : binder = android.os.BinderProxy@5c1130d, pid : 2368, uid : 10062
 18.990  2368  2368 D     ScoverManager: registerListener
 18.990  1347  2621 D     CoverManagerWhiteLists: isAllowedToUse : SIGNATURE_MATCH
 18.990  1347  2763 D     CoverManagerWhiteLists: isAllowedToUse : SIGNATURE_MATCH
 18.990  1347  2763 D     CoverManager.StateNotifier: registerListenerCallback : binder = android.os.BinderProxy@fdd2c10, pid : 2368, uid : 10062, type : 1
 18.990  1347  1347 I     KnoxTimeoutHandler: Shared devices show user statefalse
 18.990  2368  2368 D     Recents_RecentsActivity: onPause
 18.990  2368  2368 D     Recents_RecentsActivity: onNewIntent
 18.990  2368  2368 D     Recents_RecentsActivity: onResume
 19.000   971  1476 V     audio_hw_primary: out_get_latency: Latency 80
 19.000  2368  2368 D     View    : mTwDrawDuringWindowsAnimating=true
 19.000  2368  2368 D     MultiPhoneWindow: performUpdateVisibility, same visibility false
 19.010   971  1476 V     audio_hw_primary: out_get_latency: Latency 80
 19.010  9097  9097 I     Process : Sending signal. PID: 9097 SIG: 9


Some additional information (9/19)

I have been testing on a Galaxy S7 (SM-G930V Android version 6.0.1 API 23 64bit).

I exported the Unity project to Android studio and have debugged it both on the device and in emulation (Nexus 5X Android version 6.0 API 23 x86 64bit).

On the emulator it works fine and I can step through every part the OnPause call.

On the device it crashes at some point after the super.OnPause call from OnPause in UnityPlayerActivity.java and I can't step through because the source lines don't match the calls being made. For example stepping into OnPause goes to OnDestroy and at some point steps into a function called handlePause() that is not in the android SDK yet it says is in android\view\Window.java.
Eventually it calls enqueMessage with msg = { when=-10d1h27m59s804ms what=2269 obj=PAUSE target=android.os.Handler } after which it crashes.

I'm still debugging this, but I'm hoping that someone has gone down this particular rabbit hole so I can get past this.

androidfocustest.zip (32.0 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bonfire-Boy · Sep 20, 2016 at 02:05 PM 1
Share

I'm probably missing something but have you actually confirmed that it is crashing, and at that particular point? (rather than, for example, when the app gets paused).

And sorry this probably isn't very useful but can you confirm that other apps do stay active? I'm only asking because someone I was working with once spent ages trying to work out the cause of similar behaviour, only to eventually realise they'd got "Don't keep activities" set to true in their android Developer Settings

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by AltairHVS · Sep 20, 2016 at 03:51 PM

The "Do not keep activities" developer setting was the problem. Thank you!

That seems like a dangerous setting to have defaulted to ON and at the very bottom of a long list.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Pause game when user pulls down the notification panel 0 Answers

Stop Unity Play 1 Answer

Why does onDestroy in UnityPlayerActivity kill the entire process (Android) 4 Answers

How to Focus GUI.TextArea in Unity for Android 0 Answers

Button Focus Prevents Touch Raycast (Android C#) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges