UIEditBox - Lag of up to 5 seconds on iOS

UIEditBox - Lag of up to 5 seconds on iOS
0.0 0


When starting the editing (opening the keyboard) of an UIEditBox it sometimes takes up to 5 seconds until it really opens.
Until then the app is completely frozen. Does anybody have an idea what’s going on there or how to fix this?


I investigated a bit more, and it’s still truly random to me, unfortunately. The iOS keyboard freezes like crazy. Sometimes it seems to happen more often if I press spacebar. I’ve never seen this happen in any app.

Here’s the code I create the EditBox with:

    ui::Scale9Sprite *editBoxBG = ui::Scale9Sprite::createWithSpriteFrameName(backgroundSpriteFrameScaleNine);
    _editBox = ui::EditBox::create(Size(0.0, fontSize * 1.8), editBoxBG);


I think I’ve seen this, and it was random as you say, but luckily I’ve only used EditBox for entering name only at beginning process.

I’m sure there’s some way to improve or make it consistent, but it may be something in the way UITextBox (iOS) works when there’s an OpenGL view??

I’ll be curious if you or anyone finds a solution that opens consistently.


Yes, I also plan to only use it for letting the player enter their name, though I’ve seen lags of 10+ seconds in the meantime and any reasonable user would think that’s it - the app crashed :wink:

Though after 10 seconds the keyboard starts working again. It’s super weird…But you might be right. It could be an issue with standard iOS controls + OpenGL View.


All I can add is I’ve only seen 3-5 sec delays, prob closer to 3. It’s noticeable, but haven’t found/heard it to be of any issue … 10 sec would be rough though, hope you find a solution.


@slackmoehrle @ricardo

Sorry for paging you guys, but I’m really hoping that somebody of the dev team can take a look at what’s going on. The EditBox would be such a great UI element, but it’s outright broken. Every single time the keyboard opens there’s a 50% chance of a 10 second full app freeze.


Here’s a screenshot of the StackTrace. The stuff above becomeFirstResponder changes if I stop at different times.


is this iOS 10?


Yes, latest iOS consumer version (10.2.1).


@framusrock what does it mean?



When those 10 seconds freezes appear, I’ve got plenty of time to stop the app manually and check where it’s hanging. Every time I stop the app it’s stopping at openKeyboard, though the calls above obenKeyboard in the Stacktrace are not always the same. With above I mean, from 0 to 17 in the screenshot, openKeyboard being position 18. It could also be from 0 to 15, I’m not 100% sure which of those are always the same, though the upmost few are always different.

So it seems like, it’s really doing a lot of things in those 10 seconds to open the keyboard for some reason, enough to cause a 10 seconds freeze.


Got it, i will try to reproduce it first.


I can not reproduce it. The keyboard pops up very quickly. I use your codes in cpp-empty-test with latest github codes. Could you please provide a full test case to reproduce it. My environment is:

  • iphone 6
  • iOS 10.2.1


@zhangxm I also updated my Cocos2d-x version to the latest today to make that this isn’t the issue. I also created a test project with just an EditBox and nothing else on the screen and it doesn’t really happen there. “Best” I got was a 2 second lag (which is still a big issue actually). Also the error is very random, so I guess we each created the same demo project.

Maybe this bug only happens if there’s a lot of pressure on the device already / many nodes are present and the OpenGL view has a lot to do. I don’t really know what exactly triggers it.

I made a video to show you how bad it lags in my actual project. I’m opening the keyboard via code when the popup appears. But the same lags also happen if I just show an EditBox and than tap it.

While I can not send you a repro project, I can offer that we skype and I show you what’s going on via screen share if that helps debugging it.


Yep, it may be the case. I will check the logic how to open keyboard.


@zhangxm Thank you, in the meantime I also had 3-5 second freezes during the keyboard was already open and entering text via the keyboard. The keys just stay pressed and after the lag is gone the new character enters and it goes on. Maybe this also helps.


@zhangxm Is there any fix in sight for this?


Sorry, i am busy for releasing v3.15 these days.


@zhangxm I see, but wouldn’t that be an awesome fix to put into 3.15? :wink:


Yep, it would be great. But i can not reproduce it.