archagon / tasty-imitation-keyboard

A custom keyboard for iOS8 that serves as a tasty imitation of the default Apple keyboard. Built using Swift and the latest Apple technologies!
BSD 3-Clause "New" or "Revised" License
1.2k stars 290 forks source link

iPad Landscape mode bug #56

Open pirrate opened 9 years ago

pirrate commented 9 years ago

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.

archagon commented 9 years ago

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

archagon commented 9 years ago

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

pirrate commented 9 years ago

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

archagon commented 9 years ago

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.)

pirrate commented 9 years ago

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.

archagon commented 9 years ago

That's weird...

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

bbqsrc commented 9 years ago

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.

pirrate commented 9 years ago

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?

bbqsrc commented 9 years ago

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

pirrate commented 9 years ago

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.

archagon commented 9 years ago

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 commented 9 years ago

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

pirrate commented 9 years ago

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?

archagon commented 9 years ago

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 commented 9 years ago

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.)

pirrate commented 9 years ago

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

bbqsrc commented 9 years ago

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 commented 9 years ago

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

bbqsrc commented 9 years ago

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.

archagon commented 9 years ago

HERE THERE BE DRAGONS

(it's not done yet)

archagon commented 9 years ago

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.

bbqsrc commented 9 years ago

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 commented 9 years ago

@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.

pirrate commented 9 years ago

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 commented 9 years ago

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.

archagon commented 9 years ago

Thanks! Working on it.

archagon commented 9 years ago

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 commented 9 years ago

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

pirrate commented 9 years ago

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!

bbqsrc commented 9 years ago

@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 commented 9 years ago

So I looked closer at the code, and getShape already has a TODO listing this as a known issue. :stuck_out_tongue_closed_eyes:

jermiy commented 9 years ago

Hey @bbqsrc how did you make the top of the keyboard to appear like that. Please help here.

bbqsrc commented 9 years ago

@jermiy: look at my fork. Of particular interest will be the GiellaKeyboard.swift file.

jermiy commented 9 years ago

@bbqsrc thank you very much for fast help. these are the screen shot i have that it wasn't properly indented. I don't know if thats the right word though. the first pic is @archagon version and it was perfect and the second one is the one you sent me

screen shot 2014-12-11 at 4 42 31 am copy screen shot 2014-12-11 at 4 45 49 am copy

and i thank you again.

bbqsrc commented 9 years ago

@jermiy: I just noticed I had issues disabled on my fork. If you could delete your comment above and post it on my fork (so we don't annoy @archagon), that'd be great.

archagon commented 9 years ago

Wait up, I'm leaving this open until I merge the branch.

davidpaul0880 commented 9 years ago

just checked the latest merged code , still having the same issue as bbqsrc specified. If we add two Shift buttons, Only one of the shift buttons draws the icon now.

pirrate commented 9 years ago

Keyboard still lagging when you type fast on iPad. So it is not possible to write fast and correct. Will really appreciate if you fix that.

archagon commented 9 years ago

What iPad do you have? I have an iPad 3 and all my keyboards are laggy at this point, to be honest.

pirrate commented 9 years ago

i use iPad 2. Sometimes it is event changing to other keyboard automatically. it still have performance issues.