Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Android build project freezes after 5 minutes with playerloop in profiler at 60,000 ms

Discussion in 'Android' started by danteswap, Apr 8, 2020.

  1. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    I am Developing an android game ,Which just had 1 scene, All Was fine now was the time to test it on the device , so i builded the game using build and run with developement mode enabled and auto connect profiler enabled , and game runs fine , but after some time like 5 to 15 min the game freezes , so i starting disabling everything in my scene with building and running again and again , now everything in my scene is disabled , And just 1 camera 1 plane and a fps counter is enabled and still when i build and run my game freezes after 5-15 min of run on the android device one plus 3t , This is the screenshot of the profiler after the freezing happened. Unity 2019.3.8f1

    this this is annoying me so much because now everything on the scene is disabled , with just a camera a plane and a frame counter,
    Please help me
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,875
    Did you check the logcat? Maybe there are some errors?
     
  3. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    Hi There Thanks For The Reply So For Logging I am Using"C:\Program Files\Unity\Hub\Editor\2019.3.3f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\monitor.bat" with unity filters , and i am not seeing any errors in there , to be precise all the logs for androids are showing , and for unity filter i can see default logs with tag info but no error Logs with tag Error "E" .
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,875
    The error is not necessarily with Priority Error, you should filter by process id, not by Unity alone.

    Try downloading Android Logcat package via Package Manager it has filtering by package.
     
  5. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    Ok I will Try That And Post You Back
     
  6. xiangyi88889999

    xiangyi88889999

    Joined:
    Nov 7, 2018
    Posts:
    4
    I encountered the same problem, and I haven't found a solution yet. Have you solved it now?
    Or already have a clue?

    Unity 2019.3.8f1,Unity 2019.3.9f1,Unity 2019.3.10f1 same problem.
     
    Last edited: Apr 24, 2020
  7. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    Ya sure I Fixed It By Disabling Optimized Frame Pacing In PlayerSettings>ResolutionAndPresentation>Optimized Frame Pacing , if This Works For You Then be Sure To Notify here , Welcome
     
    EZaca, yuliyF, TeiKim2 and 5 others like this.
  8. xiangyi88889999

    xiangyi88889999

    Joined:
    Nov 7, 2018
    Posts:
    4
    Thank you for your help
     
  9. LuyaGames

    LuyaGames

    Joined:
    Jan 22, 2019
    Posts:
    19
    Had almost the same problem with Unity 2019.3.10 and 2019.3.13 when running my game on a TCL Android TV. The game was freezing after 5min, only music was still playing. Disabling Optimized frame pacing fixed it. Thank you very much!
     
    EZaca likes this.
  10. inxidious

    inxidious

    Joined:
    Nov 8, 2013
    Posts:
    22
    Having the same problem with Unity 2019.4.12f1
    Disabling Optimized frame pacing fixed it
     
  11. Gileno

    Gileno

    Joined:
    Nov 23, 2018
    Posts:
    29
    I have the same problem with Unity 2020.1.4f1 and disabling optimized frame pacing didnt fixed.

    What else can I do to fix this problem of the game freezing on android after a few minutes?
     
  12. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    first you need to check if not any of tour scripts are causing the problem to do that try a build with no scripts with just the visuals and then gradually adding scripts to the build and testing , if the build without the script is also freezes that try monitering the profiler in rendering section the the vsync is taking over 999ms or not , also you can try disabling the vsync at first and us a fixed resolution . in short you need to figure out the cause then only you can solve the problem , try vsync fix,.
     
  13. Gileno

    Gileno

    Joined:
    Nov 23, 2018
    Posts:
    29
    I disable vsync and it keeps freezing after a few minutes playing on my android. My game its a tower defense.

    Before, the warning below appeared when I built the apk

    Game scripts or other custom code contains OnMouse_ event handlers. Presence of such handlers might impact performance on handheld devices.
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)


    I already switched all OnMouseDown method for GetTouch and now no more warnings appear but the problem persists .

    It is difficult for the game to run without a script because without the most important classes, which is turret, bullet and enemies the game does not work.

    I've tried with just one scene, with only one type of tower, with a reduced amount of enemies, but it still freezes after a few minutes.
     
  14. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    All you fixing this by disabling Optimized Frame Pacing, could you please report a bug in the (Editor via Help > Report A Bug) on this with your Project so that OFP can get fixed? If that leads to duplicates, that's better than no reports as it just provides additional context narrowing this down.
     
    Last edited: Feb 14, 2021
    EZaca likes this.
  15. Gileno

    Gileno

    Joined:
    Nov 23, 2018
    Posts:
    29
    Hi MartinTilo, ty for answer.

    I tested the game on a friend's cell phone (a good one) and he played it without freezing. My cell phone is old and that must be the problem.

    After seeing your signature on optmization, best practices and other things, I am improving some codes within the update methods and I believe that this will solve the situation. If not, I'll be back. Thanks.
     
    danteswap and MartinTilo like this.
  16. DovitItalia

    DovitItalia

    Joined:
    Mar 23, 2020
    Posts:
    50
    I had this problem too, and i now realize that Optimized Frame Pacing can be the cause of it, I was working on the app on a new device this morning and noticed a suddent and unexpected freeze, checking the log I found the same behaviour I described here: https://forum.unity.com/threads/uni...ication-after-migrate-to-unity-2019-3.907628/ and after a bit of googling I found this post.

    Disabling Optimized Frame Pacing seems to have solved (so far) the issue.
    @MartinTilo back in the days I sent a bug report about it (case 1254991) If is unavailable to you I'm happy to send another one if you need
     
  17. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    That bug report was closed as it seemed tricky to nail it down. Reading through the history on that, it looks like it might've been resolved because the the default settings in a new 2019.4 build would be different than those of a project upgraded from 2017.4, but no determination was reached as to what that difference actually was? If that difference is the Optimized Frame Pacing setting or if there is a new and different expression of this that hinges on this setting, then a new bug report on this would be useful, yes :) If it is as easy to reproduce as flipping that setting, that should be way easier to find with an example project and that hint.
     
  18. DovitItalia

    DovitItalia

    Joined:
    Mar 23, 2020
    Posts:
    50
    I can confirm you that by toggling the Optimized Frame Pacing on and off the problem is sistematically reproduceable.

    Using the Android Profiler (from android studio tools) under the CPU i can see the thread "filter0" and "filter1" appear ONLY when that option is toggle on, moreover, those two thread are basically idleing most of the time. When they idle the application works smoothly but, when they run no-stop (like in the picture) the application is freezed. No particular actions are done from app side to trigger those. I saw this situation with the app simple opened and left alone for a couple of hours. Schermata 2021-02-26 alle 16.28.50.png

    I just sent a bug report for you with the same project I'm seeing this behaviour
     
    MartinTilo likes this.
  19. athensM

    athensM

    Joined:
    Mar 18, 2021
    Posts:
    10
    Hi,

    Disabling the Optimized Frame Pacing option did not solve this for me. My app still freezes after about 7 hours of runtime.
     
  20. Cerberus_team

    Cerberus_team

    Joined:
    Apr 9, 2014
    Posts:
    40
    Same problem here with Unity 2020.3.16f1, disabling Optimized frame pacing fixed the issue.

    Anyone knows the status of this bug?
     
  21. HernandoNJ

    HernandoNJ

    Joined:
    May 13, 2018
    Posts:
    75
    Worked for me
     
  22. noobogami

    noobogami

    Joined:
    Jul 24, 2021
    Posts:
    44
    I made a shader with shader graph and put it in game and since then game freeze after a few minutes.
    it happens on a samsung a10 more frequently than a redmi note 8 (it just happened few time on this device)
    when I'm disabling object that has shader problem will fix.
    for specifying problem I have a tilemap that use "extra 2d tilemap" package and my material is set on that.
    and Optimized frame pacing is disabled
     
  23. noobogami

    noobogami

    Joined:
    Jul 24, 2021
    Posts:
    44
    I removed shader and problem persisted finally I figured out that the tilemap cause freeze and when I disable tilemap object freeze won't happen.
    now question is "why tilemap or 2d extra tilemap package cause freeze?"
     
  24. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    That is a very good question but I have a strong suspicion that this down to a different root cause to the issues discussed in this thread so far, as no one brought up tilemaps so far and Optimized frame pacing doesn't seem to be the culprit.

    This sounds like there should be some rather straight forward repro in your project though that would be very valuable to capture and analyze on our side. Could you please file a bug report on this via Help > Report a Bug in your Editor?

    I have a feeling this would otherwise be tricky to discuss in theory here in the forums. You're also welcome to open a thread in the 2D or 2D Experimental preview Packages subforums. It's more likely that that will surface the thread and your issue to others with similar / same issues and the 2D team. Still, the most ideal would be a bug report so that this can get analyzed and fixed.
     
  25. noobogami

    noobogami

    Joined:
    Jul 24, 2021
    Posts:
    44
    When I post the question I didn't know tilemap cause this. yesterday I filled a bug report and I'm continuing discussion in github and related subforum.
    thank you for response.
     
    MartinTilo likes this.
  26. zhong317

    zhong317

    Joined:
    Sep 27, 2017
    Posts:
    4
    I encountered the same problem In Unity 2020.3.x.

    When My game runs for a certain period of time, the game will occasionally get stuck. It took a long time to find out that the "Fitler0" and "Filter1" thread take a lot of CPU, and they are related to the "Optimazed Frame Pacing" option. We're not sure what's causing these two threads to get stuck, but from the post above, they seem to have a similar problem with nothing they do. The current solution can only be to turn off the "Optimized Frame Pacing".

    This option is enabled by default in the Unity 2020 version, and we don't know the specific cause of this problem. The risks brought by this option seem to be much higher than the benefits it brings. I hope the Official will pay attention to it, I believe There are still many people who are frustrated by this hidden and unknown problem.
     
  27. IgorGalimskiFMGames

    IgorGalimskiFMGames

    Joined:
    Jul 21, 2021
    Posts:
    16
    Have this issue
    Unity 2020.3.20f1
    After 10 mins in idle state - gameplay is completely frozen

    Disable 'optimizedFramePacing' helped
     
    Last edited: Jun 2, 2022
  28. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    At @zhong317 and @IgorGalimskiFMGames:
    If you encounter the Optimizing Frame Packing bug, please please please file a bug report for it via
    Editor > Report a Bug
    . It is weirdly elusive and we need all the details we can get to fix fix Thank you :)
     
  29. pevi

    pevi

    Joined:
    May 25, 2014
    Posts:
    3
    I will try that option.

    In my phone Samsung S21 FE my game frezee too. And without any several charge in the screen (a simple menu).

    I play a lot of Magic Arena, maked in Unity, and i get a lot of frezzes states. Others friends play with other mobiles than samsung and older, and no frezee.

    I think there is something bad in this combination: Unity + Samsung Mobiles.

    Edit: Also it can be with the Universal Render Pipeline, but i am not sure. I think if i configure a low quality the frezzes appears less.
     
  30. risenlin

    risenlin

    Joined:
    Jul 13, 2016
    Posts:
    1
    Does anyone know what are the Filter0 and Filter1 thread?
    I develop application for Car Central Screen(Android Device),and I notice that our application's cpu cost is really weird.
    While on the real car the Filter0 and Filter1 will take 60%~80% (total 400%)cpu,and the callstack of these two thread are all about 'Choreographer'.But the 'UnityChoreographer' thread is already there.
    BTW,the UnityEditor version is 2020.3.2f1
     
  31. vedantshinde19645

    vedantshinde19645

    Joined:
    Jun 27, 2022
    Posts:
    1
    7 hours :)
     
    EZaca, Davex6 and noobogami like this.
  32. scryedzxp

    scryedzxp

    Joined:
    May 14, 2013
    Posts:
    47
    Been seeing this same problem with 2021.3.25 LTS and 2022.3.0 LTS on my Samsung Galaxy S7 Edge.

    In both versions, I set up a simple scene with a camera and a 2D square sprite. The sprite continuously oscillates left and right (script included below).

    For 2021.3.25 LTS, the app freezes (i.e. the sprite stops moving) after the app has been running for 2-15 minutes. I tested this many times and it froze each time.

    For 2022.3.0 LTS, it freezes at around 20 minutes. I tested this twice and it froze each time.

    After seeing these suggestions for disabling Optimized Frame Pacing, I tried disabling it for 2022.3.0 LTS and let that same scene run five times for an hour straight each time (a total of 5 hours) and it didn't freeze once.

    I did not try to disable Optimized Frame Pacing for 2021.3.25 LTS.
     

    Attached Files:

    Last edited: Jun 7, 2023
  33. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    Can you please report a bug with a project and that script in in via the Editor menu
    Help > Report A Bug
    ?
     
    scryedzxp likes this.
  34. pablo_leban

    pablo_leban

    Joined:
    Sep 19, 2013
    Posts:
    68
    In my case, the app freezes after 5-10 minutes. Optimized Frame Pacing is off. This only happens if I build the game on Unity 2022. Downgrading to Unity 2021 fixes the issue, but it's not a good long term solution. This started to happen after updating from Unity 2021 LTS to Unity 2022 LTS.



    Some details
    • The game just completetly freezes, while the background music keeps playing, but it's not a render issue only as the game should be playing other sounds which also stops. It looks more like a Time.timeScale = 0 and UI/input doesn't do anything.
    • I've tried this with high end phones, and I wasn't able to reproduce this.
    • Someone having this issue sent me the logcat, which I'm attatching here, but there are no signs of crashes or weird logs there (the game is called Idle Slayer). We've used adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG
    • I'm using Firebase Crashlytics and there are no signs of such ANR. Not even in the Google Play Console. I believe that the game actually never crashes or is considered as an ANR so it never gets reported to those platforms.
    Affected Devices that reported this issue
    • Samsung Galaxy A04S (2 different devices)
    • Samsung Galaxy A11
    • Samsung Galaxy A12
    • Samsung Galaxy A21S (2 different devices)
    • Samsung Galaxy S20 (4 different devices)
    • Samsung Galaxy S20+
    • Samsung Galaxy M62
    • Samsung Galaxy S20 FE
    • Samsung Galaxy S10 (2 different devices)
    • Samsung Galaxy Note 20 Ultra
    • Samsung Galaxy Note 10+
    • Xiaomi Mi Mix 2S
    • Xiaomi Redmi Note 8 Pro
    I'll keep updating this list as I keep receiving reports from players.

    I've also reported a bug from the editor which is case IN-44716

    If you need additional information, please let me know.
     

    Attached Files:

    Last edited: Jun 23, 2023
  35. vg_swift-games

    vg_swift-games

    Joined:
    Aug 2, 2021
    Posts:
    26
    For us this issue also started happening after upgrading from Unity 2021.3.20f1 to Unity 2022.3.1f1 or Unity 2022.3.2f1.
    Switching Optimized Frame Pacing option doesn't change anything.

    Affected Devices that reported this issue:
    samsung SM-A526U (Samsung Galaxy A52 5G)
    samsung SM-S908W (Samsung Galaxy S22 Ultra)
    samsung SM-N986B (Samsung Galaxy Note 20 Ultra 5G)
    samsung SM-G985F (Samsung Galaxy S20+)
    samsung SM-G980F (Samsung Galaxy S20)

    We tried to reproduce this issue on multiple devices, including some Samsungs, but couldn't reproduce it locally.

    Same as @pablo_leban mentioned, there are no logs, nothing appears in Crashlytics or Google Console. The game just freezes, the device doesn't seem to get hot during the freeze though. (we don't use Tilemaps)

    For players that have this issue, it's a 100% reproduction rate. It freezes a few minutes after starting the game.
    Not sure if relevant, but we are using URP with OpenGLES3 prioritized over Vulkan.
     
    Last edited: Jun 21, 2023
  36. vg_swift-games

    vg_swift-games

    Joined:
    Aug 2, 2021
    Posts:
    26
    Swithching priority back to Vulkan seems to fix the issue. But could confirm with just one player so far.

    Actually it didn't help, it just moved the freezes back, so they happen a bit later. More players confirmed it now.
     
    Last edited: Jun 22, 2023
  37. pablo_leban

    pablo_leban

    Joined:
    Sep 19, 2013
    Posts:
    68
    This has been my Graphics API for a long time, so that shouldn't be the problem in my case.

    upload_2023-6-21_15-55-4.png
     
  38. vg_swift-games

    vg_swift-games

    Joined:
    Aug 2, 2021
    Posts:
    26
    Yeah, I just updated my previous post, it didn't really work.
    Unfortunately Unity 2022 LTS is unusable for us right now due to this issue, so we are forced to downgrade back to 2021.
     
    Last edited: Jun 22, 2023
  39. SimStar

    SimStar

    Joined:
    Mar 25, 2013
    Posts:
    1
    We've also been experiencing this freeze on Samsung S20 5G. Unity 2022.3 LTS + Optimized frame pacing off. Adding more cameras to the scene seems to greatly exacerbate the issue, causing freezes to happen within the first minute or so but its inconsistent.
    We've tried every combination of graphics API / multithreaded rendering / graphics job with no luck. No errors output to logcat even with no filter applied. We captured a stack trace via Android Studio when the freeze occurred. It appears the Unity main thread is getting deadlocked in CullScene function. Its always this exact stack trace every time it freezes:

    syscall
    UnityClassic::Baselib_SystemFutex_Wait(int*, int, unsigned int)
    ujob_wait_for(ujob_control_t*, ujob_handle_t, int)
    CompleteFenceInternal(JobFence&, WorkStealMode)
    CullScene(CullResults&)
    Camera::CustomCull(CameraCullingParameters const&, CullResults&, bool)
    RenderManager::RenderOffscreenCameras()
    PlayerRender(bool)

    We've tried with both Universal and built-in render pipeline and the freeze persists. They both call this function under the hood. Enabling multithreaded rendering / graphics jobs / vulkan / doing a production build and reducing the number of cameras rendering each frame reduces the occurrence but the freeze still occurs after waiting long enough.

    Its easy to repro in a blank project. Just add some cubes to the scene, add a whole bunch of cameras (we did about 120) and deploy an il2cpp build to one of the specified android devices. After a few minutes you'll see a freeze.
    We've reported a bug.
    Attached screenshot shows the point in CullScene when the CompleteFenceInternal is called that freezes.
     

    Attached Files:

    Last edited: Jun 25, 2023
  40. Ts1nd

    Ts1nd

    Joined:
    Jan 24, 2021
    Posts:
    108
    Any update on this? Started happening for me after upgrading to 2022 LTS...
     
  41. Ts1nd

    Ts1nd

    Joined:
    Jan 24, 2021
    Posts:
    108
    I did a lot of testing, changed different setting and disabled features one by one to finally find what is the source of the issue...
    First of all, it doesn't happen after downgrading to 2022.2.15f. That is not an option for me as I need decal layers...
    The reason for the issue in 2022.3.x version is camera stacking. Deactivating the overlay camera and (in my case) displaying the UI on the main one (to show every layer again) will fix the issue... but that's not a good solution either as now the healthbars are covered by objects. If anyone knows how to display UI on top of objects without camera overlays, please use this topic as I did not get an answer yet:
    Discussion - Alternatives for displaying world space UI on top of objects - Unity Forum

    I hope it was helpful for the devs to start looking why camera overlays cause this rendering freeze.
     
    Last edited: Jul 10, 2023
  42. pablo_leban

    pablo_leban

    Joined:
    Sep 19, 2013
    Posts:
    68
    Last edited: Jul 15, 2023
    konsnos, mo392, NEOPOP and 4 others like this.
  43. ColinBroderick

    ColinBroderick

    Joined:
    Mar 1, 2022
    Posts:
    9
    I have been suffering an issue similar to this for a long time. In my case it seems to be connected to the use of the WebSocket-Sharp library (including net-standard and various forks), as it only occurs when an object using it is enabled in the scene.

    The application just freezes. The rest of the system is fine. There are no error messages on logcat or anywhere else I can find so it is proving extremely difficult to diagnose.
     
  44. vg_swift-games

    vg_swift-games

    Joined:
    Aug 2, 2021
    Posts:
    26
    44 votes now, no updates from Unity yet
     
    phuc12610 likes this.
  45. ErezShahaf

    ErezShahaf

    Joined:
    Feb 3, 2022
    Posts:
    70
    I am experiencing this issue as well, some times in the form of freezes, some times it crashes and closes, and sometimes it minimizes the game and when I focus back it is frozen.
     
    Last edited: Jul 30, 2023
  46. Yavuz_Selim

    Yavuz_Selim

    Joined:
    Apr 16, 2021
    Posts:
    11
    I am using Unity version 2023.1, and even though I have disabled the Optimized Frame Pacing feature, I also encountered this problem. I was testing my game using my own phone, which has lower specifications, and I never experienced this issue. However, when I tested the game on different and higher-spec phones, I encountered this problem on some phone models.

    I made the following observation: On the phone models experiencing the problem, it doesn't occur when I set the quality to "Very Low" or "Low," but it only happens at medium and higher quality levels. I must emphasize that these phones should not experience freezing issues even at medium and higher quality settings. Even on my own phone, I can play the game at 60 fps with the "ultra" setting.

    In another forum thread, I came across a post where someone resolved the issue by removing terrain trees: https://forum.unity.com/threads/uni...g-on-a-scene-with-open-world-terrain.1434625/

    To those experiencing the problem, if they can confirm that the issue doesn't occur when lowering the quality settings, maybe we can narrow down the scope.
     
    Last edited: Aug 24, 2023
  47. JeremyPark2

    JeremyPark2

    Joined:
    Jul 16, 2021
    Posts:
    1
    I'm also having the same issue. so I'm downgrading to 2021.3.29f. i dont use HDRP and URP. my game is just simple casino~. i dont understand it..
    i hope qucikly fix
     
  48. pablo_leban

    pablo_leban

    Joined:
    Sep 19, 2013
    Posts:
    68
    The issue has been updated and it's now under Consideration for 2021.3.X, 2022.3.X, 2023.1.X, 2023.2.X, 2023.3.X!

    I hope this is fixed soon.
     
    dendyak likes this.
  49. dendyak

    dendyak

    Joined:
    Mar 7, 2015
    Posts:
    27
    Same issue on Unity 2022.2.9, 2022.3.5 LTS and 2022.3.7 LTS. Optimized Frame Pacing is OFF. It happens on some devices like Samsung Galaxy M12, Galaxy A12, Galaxy A21s, Galaxy A6+, Techno Spark 10, Realme C21-Y...
    I have Galaxy M12 and was trying to find out where the problem, but the phone just freezing in any scene even on first scene where are no graphics objects, just some initialization scripts. The strangest thing is that this does not happen on an empty project at all. Seems to be it is related with number of script objects or number of objects in Assets\Resources.

    P.s. and same project works fine on mentioned devices if I build it using old Unity 2021.3.9
     
    Last edited: Aug 20, 2023
  50. dendyak

    dendyak

    Joined:
    Mar 7, 2015
    Posts:
    27
    The problem was in Application.targetFrameRate, if you don't use it, the Android build on Unity 2022 doesn't freeze so often..
     
    Last edited: Aug 21, 2023