iPhoneKeyboard causing weird unrelated issues

Debugging an issue in our game when the data is persisted to the PayerPrefs during gameplay and the whole game seems to pause for a moment that is very noticeable. Up until now we thought it only happened the first time you played the game but we have recently identified the use of iPhoneKeyboard as the reason. The fact that we usually enter our player’s name from the settings menu on the first run of the game would explain the link between first run and this issue (as it requires the keyboard to do so).

Basically, if we show the keyboard to gather input from the menu scene, for the remainder of the instance of the game (in a different scene), whenever it writes to PlayerPrefs a significant lag occurs where the whole game pauses for a fraction of a second. If the keyboard has never been displayed in any scene in the running of the game, the problem never happens.

We also noticed that when we call iPhoneKeyboard.Open for the first time there is a lengthy wait for the keyboard to open however for subsequent efforts it is practically instant to display. Is this lengthy wait the norm for the first time you show keyboard? Is there any way to fully unload / close / dispose the keyboard when you are done with it?

We have tried setting the instance variable for the keyboard = iPhoneKeyboard.Open to be null and called System.GC.Collect() as well as Application.GarbageCollectUnusedAssets() but the problem remains.

We are using iPhone 3G running OS 3.1 + unity 1.5.1fp2 and building for OS 2.2.1

Any help would be appreciated. Its a real pain in the butt bug because the game is rather un-playable. We save to PlayerPrefs on multiple events during game and having it basically ‘pause’ every time one of these events happens is really degrading the players experience.

Thanks in advance.

Hi,

Unity iPhone 1.5.1 is outdated now. You should update to the latest version of Unity iPhone (version 1.7).

If the problem remains after update, it would really helpful if you fill a bug report along with your project and I will take a look what exactly happens in your case.

Thanks.

We updated to Unity 1.6 but ended up rolling back to 1.5.1 as 1.6 completely nuked our WWW class handling on older iPhone OS devices (2.2.1 to be exact). Basically the simplest call to a WWW url was causing the app to crash.

As a result of the lengthy process we had to undertake to dig up an old installer for 1.5.1 to restore our apps functionality, and considering we are days off from releasing an update to the game in question, we are very nervous about upgrading to Unity 1.7

Can you confirm if a memory leak with the Keyboard has been resolved since Unity 1.5.1? We notice the entire game seems to be affected (With writes to the PlayerPrefs being the most delayed function) after a keyboard has been displayed in any scene / at any time in the game. Has there been any significant changes in 1.7 that would have addressed the crashing 1.6 WWW class and the memory issues with keyboards?

I’m not sure what do you mean by saying “memory leak” in context of iPhone keyboard :slight_smile:
However, I encourage you to submit a bug report with your project which clearly shows the problem with iPhoneKeyboard. I cannot confirm anything at this point since I’m not aware of problems you described.

Hi,
we are not aware of any internal WWW class crashes. Please report a bug with your project attached to it. Some people had WWW class migration issues (1.5->1.6/1.7) because they were using “busy” waiting pattern instead of yielding on WWW object. Sometimes you can see crashes in your code (null reference exceptions actually) if your code does not perform proper status/error checking.

I posted sample code (yes using the simplest WWW yield method with no special delays / wait handlers) and unity developer said they were unable to replicate while other forum developers confirmed it was crashing on their devices. I suspect it may be an issue with older OS iphones (We were running on a 2.0 iOS test device although since then we have lifted our minimum OS support device to be 2.1.1). Its not much point me going to all the trouble of making a custom project for you guys to test and come back with 'worked fine for us) as happened before.

Not sure how I can replicate the keyboard issue short of sending the entire codebase of our game and insisting you play it on a 2.2.1 3G device as the ‘lag’ im talking about isn’t obvious on a 3GS, but once we have got this update ready for deployment I will have a go at replicating it. One idea is to write a loop that will write to PlayerPrefs a few hundred times and record the time taken to do it, then popup a keyboard / close it and repeat the write to PlayerPrefs and record the time post keyboard display.

Do you guys only test on 3.x devices or do you have a set of older flashed phones (like 3G running 2.2.1 or iPod 2G with the native installed OS on it etc). Just about every issue I have reported in the past have been specific to older OS iPhones (aka the weird audio pitch issues on OS 2.0 have resolved themselves now we have raised minimum support to 2.2.1 and upgraded our devices to that OS accordingly.

And please to the other Unity developers who maintain that there is no need to support these older OS’s anymore, please save it for another thread. We do not agree and have stats that would support the counter claim. Also if you take a look at EA and Gameloft you will also notice they do not agree as well as most their games are 2.2.1 support. I think if their stats indicate its not worth upgrading to 3.x and utilising the extra functionality that would provide, then thats good enough for us, for now…