tasty-imitation-keyboard icon indicating copy to clipboard operation
tasty-imitation-keyboard copied to clipboard

iPad Landscape mode bug

Open pirrate opened this issue 10 years ago • 40 comments

Keyboard crashes on iPad landscape mode. It appears normally but whenever you click any button it crashes. I tested in real device. Urgent fix appreciated.

pirrate avatar Dec 02 '14 20:12 pirrate

Could you give more details? Crash log, etc. I just tested the master branch on the iPad Simulator and it doesn't crash.

archagon avatar Dec 02 '14 21:12 archagon

Also, does it crash on your Simulator or only on device?

archagon avatar Dec 02 '14 21:12 archagon

Only in device. Please test in real device. I have tested with 2 different devices. Same result.

pirrate avatar Dec 02 '14 21:12 pirrate

I don't have a device to test on at the moment. I would appreciate it if you could post the crash log, as well as the exact place where it crashes. (I think this will be more accurate if you run in Debug mode rather than Release.)

archagon avatar Dec 02 '14 21:12 archagon

Not able to get logs/debug now. Laptop is at home. And i always tested with simulator too. Sad thing is i dont have iPad (( I sent bundle to my friends they did test and got crash.

pirrate avatar Dec 02 '14 21:12 pirrate

That's weird...

Well, if you get your hands on the crash logs, let me know. I'll keep an eye out for it.

archagon avatar Dec 02 '14 21:12 archagon

I have been playing with this on an iPad, and it works for me in both portrait and landscape mode, BUT, if I change orientation, it crashes. If I have a debugger connected, it says: Message from debugger: Terminated due to Memory Error.

bbqsrc avatar Dec 06 '14 10:12 bbqsrc

That is exactly what is happening on my test users. If you noticed you can not type anything on landscape mode too. If you click any button it crashes. Does it same for you?

pirrate avatar Dec 06 '14 10:12 pirrate

No, pressing buttons works for me, however I have been testing with my fork so I may have fixed another issue that causes that.

bbqsrc avatar Dec 06 '14 10:12 bbqsrc

yeah, in my case it is not possible to press any button on landscape mode. it crashes immediately. Also yes it crashes when i change orientation from Portrait to Landscape. I am using master of this project.

pirrate avatar Dec 06 '14 10:12 pirrate

OK, I see what's causing the problem. It looks like memory usage on an iPad is 3x that of the iPhone for some reason. When you rotate, it goes from 30-something MB to 40-something, which is probably what causes the crash. I will try to fix. In the meantime, check the "key-reuse" branch that I just added — does it still crash there? (The branch is still incomplete.)

archagon avatar Dec 06 '14 20:12 archagon

Yikes, I'm checking with Instruments and there's some really heavy allocation going on during repeated key presses and mode switching.

archagon avatar Dec 06 '14 20:12 archagon

key reuse looks cool. works extremely faster. but i still able to increase memory when keep changing keyboards (ok lets hope it is dev tool bug). bbqsrc could you please check if it still crashed on iPad? i dont have have ipad so cant test it :( Any idea what and why causing heavy allocations?

pirrate avatar Dec 06 '14 21:12 pirrate

I think it's the fact that I have 3 CALayers and a UILabel for each key.

For iPhone keys, I'm seeing a 32kb allocation per layer. (Makes sense: (26 * 2) * (39 * 2) * 4 bytes for RGBA + whatever other stuff CALayer has is in the ballpark of 16kb-32kb.) 32 * 26 (approx keys per page) * 3 *4 = almost 10MB! And iPad keys have almost 8x the area.

I will probably try to condense the three layers into one.

archagon avatar Dec 06 '14 21:12 archagon

Incidentally, commenting out self.layer.shouldRasterize = true in KeyboardKey improves memory 2x, since I guess it doesn't actually keep buffers for all the keys. But this impacts responsiveness, so YMMV. (Also, I think it builds back up over time, as the keyboard is used.)

archagon avatar Dec 06 '14 21:12 archagon

interesting article in here http://chaosinmotion.com/blog/?p=855

pirrate avatar Dec 06 '14 22:12 pirrate

I've tested with the key-reuse branch and it no longer crashes. I'll be using this as my master in the mean time. :smile:

bbqsrc avatar Dec 07 '14 00:12 bbqsrc

It does however crash if you type some keys (10 or more) when in landscape for me.

bbqsrc avatar Dec 07 '14 01:12 bbqsrc

Heh, also, if you type really really fast, you can see the keys you pressed played back to you because it is sequentially drawing each key press and it isn't fast enough.

bbqsrc avatar Dec 07 '14 01:12 bbqsrc

HERE THERE BE DRAGONS

(it's not done yet)

archagon avatar Dec 07 '14 01:12 archagon

Oh, I think you can fix the landscape crash and maybe the key ghosting by changing the setMode(0) calls in keyPressedHelper to self.currentMode = 0. Maybe.

archagon avatar Dec 07 '14 01:12 archagon

You were right, that does fix it. And yes, I know there's dragons, but I did review the code first. I know what I'm getting myself into. :+1:

bbqsrc avatar Dec 07 '14 01:12 bbqsrc

@archagon: been playing some more. If you enable "Allow Lowercase Key Caps" and use the keyboard in landscape mode, it will still crash unfortunately.

Also, hitting shift in general causes it to crash in a disappointed way. Mash some keys, where one of them is shift, it'll die.

bbqsrc avatar Dec 07 '14 03:12 bbqsrc

Also it sometimes crashes when you use keyboard often and type really fast on iPhone. Wasn`t able to check it with this version but in previous master it was crashing.

pirrate avatar Dec 07 '14 04:12 pirrate

Kept testing key-reuse branch today. On iPhone seems like it works fine but on iPad still have problem on landscape mode. Different kind of strange crashes happens. Well, all of them because of memory for sure.

  1. Crashes when i hit enter button
  2. Crashes when i hit ?123 (char keyboard) button
  3. if i type long text then keep holding backspace to remove, it crashes somewhere, in my case it always crashed on the last character remove.

That is it for now.

pirrate avatar Dec 07 '14 20:12 pirrate

Thanks! Working on it.

archagon avatar Dec 07 '14 21:12 archagon

I think the latest commit to key-reuse should improve memory usage significantly. (But it's hard to tell, all the Instruments have different readings for memory usage!) Still need to fix the shift key memory spike, though.

archagon avatar Dec 07 '14 23:12 archagon

And the one after that should fix a lot of the problems with shift and mode switching.

archagon avatar Dec 08 '14 01:12 archagon

Works gorgeous now. trying to mess up with iPad but i am not succeeded :)) That means keyboard will fly on iPhone. Last fixes are really cool!

pirrate avatar Dec 08 '14 06:12 pirrate

@archagon: well done!

I now have a fun issue though on my fork, which is best explained with the following screenshot:

screen shot 2014-12-08 at 17 46 46

Only one of the shift buttons draws the icon now. If I change pages and come back, the button that gets drawn shifts! :laughing:

bbqsrc avatar Dec 08 '14 06:12 bbqsrc