[Android][Unity][C#][PlayerPrefs] Strange issue while resuming app
Hello!
[Problem description] Application freezes just after goin back from desktop to app (on android device). It tooks a lot of time to unfreeze (but sometimes it juct crashes).
[Where] I was debugging whole code to find a place where the problem is and I found that there's something wrong while I was saving things to Player Prefs.
[My "idea" why it is causing] Multiple times getting and setting prefs with different values.
[Test code] I will give you my test code to show what steps I was trying to check and how this bug works.
https://pastebin.com/24FM65EJ
I was thinking that maybe there's a problem with double's precision, but it wasn't. Then I checked if it is caused by parsing inside setstring methods, but it wasn't. Problem isn't connected with a key, so it can be random.
If you want to check this try to build this code with 2 different values in tmp string list (now it's 5 and 7) and there will be bug, then change these values to the same (f.e. 5 and 5). Problem will disappear. Also you can delete get or set from FOR loop and problem will also disappear.
I also made a tricky switch inside Update method to check if it is connected with this get / set pair so you can check it too.
Sorry for my english guys but this problem is so complex that I even don't know how to describe it. I am trying to solve it for 3 days (we need to solve this or make a 'walk around' because we can't use that app without this).
Thanks in advance.
Your answer
![](https://koobas.hobune.stream/wayback/20220612132929im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
CommandInvokationFailure: Unable to convert classes into dex format. 1 Answer
What is the most efficient way to spawn in a lot of cubes, like 10k? [c#] 2 Answers
When Resuming game after losing focus I just get a black screen? 0 Answers
Trees look flat on mobile using standard shader 0 Answers
lag in android device but fps is good 0 Answers