Unity-Technologies / 2d-extras

Fun 2D Stuff that we'd like to share!
Other
1.54k stars 342 forks source link

Freezing Game! #323

Open noobogami opened 2 years ago

noobogami commented 2 years ago

in my game I have a map that handle with a system similar to tilemap that I wrote myself. some part of map are cloud that can be removed during playing and I handle them temporary with some hardcode style algorithm, now for refactoring I changed that part to 2D tilemap extra and it worked very good but I noticed an issue; app freeze after period of time! first I thought it's a problem with a shader I used on clouds but when I disabled my shader and used "sprite default" material problem stayed. it happens randomly and just happens when tilemap object is active (when I change a view in my game that disables tilemap object game works without problem), all unity cycles stop (every updates stop calling) but every time I touch screen logcat show this log: 2021/11/20 12:41:28.121 4815 4815 Debug ViewRootImpl@53d11aa[UnityPlayerActivity] ViewPostIme pointer 0 and "Game Analytics" cycle works and looking for new events to send every 20 or 30 seconds with this log: 2021/11/20 12:43:13.660 4815 5535 Info GameAnalytics Info/GameAnalytics: Event queue: No events to send I use a custom ruletile for my cloud so 3 different tiles connect to eachother, here's my code:

public class MultiTextureTile : RuleTile<MultiTextureTile.Neighbor> {
    public TileBase[] tilesToConnect;

    public class Neighbor : RuleTile.TilingRule.Neighbor {    }

    public override bool RuleMatch(int neighbor, TileBase tile) {
        switch (neighbor) {
            case Neighbor.This: return tile == this || tilesToConnect.Contains(tile);
            case Neighbor.NotThis: return tile != this && !tilesToConnect.Contains(tile);;
        }
        return base.RuleMatch(neighbor, tile);
    }
}

when I tried to use profiler it didn't happened in first build but in another build it frizzed with profiler and at the time of freeze profiler graph stopped moving! there was no spike in cpu or render or memory. I tested on two different devices a Samsung Galaxy A10 that freezes almost every time and a Xiaomi Redmi Note 8 that rarely freezes (I just saw two or three times) freezing time is different. sometimes it wait 2 minutes, and sometimes it freeze in less than a minute. I'm using Unity 2019.4.18

ChuanXin-Unity commented 2 years ago

Would it be possible to share what you have captured in the Profiler and provide details of the Frames where it stalls? You can also turn on "Deep Profile" to get more details of what is happening in the freezing Frame if nothing much shows there by default.

noobogami commented 2 years ago

I tried with deep profile but it didn't freeze here's simple profile result after freezing this graph didn't update anymore image image image image

ChuanXin-Unity commented 2 years ago

Unfortunately, this does not provide any details about the freeze, which makes it difficult to figure out the issue. Perhaps you could try using the Android Profiler or try to capture the callstack when you encounter a freeze.

Would it be possible to send a bug report with your project using the Unity Bug Reporter and steps on how to reproduce this issue?

noobogami commented 2 years ago

Unfortunately, this does not provide any details about the freeze, which makes it difficult to figure out the issue. Perhaps you could try using the Android Profiler or try to capture the callstack when you encounter a freeze.

Would it be possible to send a bug report with your project using the Unity Bug Reporter and steps on how to reproduce this issue?

yesterday I filled a bug report and after several attempts finally I could send it, until now I didn't receive any response from unity about receiving bug report (as I think it said in final message that they would send an email after delivery). I sent my built file with bug report too. for now I disabled tilemap and use my previous version of clouds until find a solution to this problem.