We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4659 - iOS: UIAlerController Text not getting focus
Summary: iOS: UIAlerController Text not getting focus
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.1
Hardware: iPhone/iPod touch iOS (All)
: P2 blocker
Assignee: Alex Szpakowski
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-08 19:34 UTC by Dominik Reichardt
Modified: 2019-06-21 14:42 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dominik Reichardt 2019-06-08 19:34:25 UTC
Since Changeset 12682 https://hg.libsdl.org/SDL/rev/aec854f934db touch inputs were borked but somewhat resolved with Sam's changeset 12728 https://hg.libsdl.org/SDL/rev/24cff6812c23

However an UIAlertController Textfield still does not get "focus" and the softkeyboard does not get triggered.
Not get focus means that you cannot put the "cursor" in the text field, nor can you hit ok or dismiss. Every touch is registered in the gameview below the UIAlertController.

I do not have an easy test case, it happens with Exult's iOS port https://github.com/litchie/exult-ios which also needs the game files to be testable (I can easily provide those outside of a public upload).

Screenvideo of iOS Simulator and working UIAlertController with SDL2 2.0.9 https://youtu.be/6ABFZWUYIW0
Screenvideo of iOS Siumulator not working UIAlertController with hg https://youtu.be/wB7YBYq_F28

IMO this is a critical, blocking bug that should not be unfixed in 2.0.10 (unless we did something wrong that only now surfaces).
Comment 1 Sam Lantinga 2019-06-08 21:43:49 UTC
Alex, can you take a look at this?

Thanks!
Comment 2 Dominik Reichardt 2019-06-09 13:22:45 UTC
Curiosly this is working correctly with the beta of the iOS 13 SDK.
Comment 3 Dominik Reichardt 2019-06-10 22:28:35 UTC
Changing the way Exult displays the UIAlertControl fixed it on my end. https://github.com/litchie/exult-ios/commit/bc4f1c6a36304b1ba73bf5e763bdbee337d73008

So, for some reason this worked before these changesets and works in the iOS 13 SDK beta, but after all, I think I just created the alertcontrol wrong and was just lucky before.

What is your opinion Alex?
Comment 4 Alex Szpakowski 2019-06-12 21:52:36 UTC
I've tried to reproduce this locally by modifying SDL's implementation of ShowMessageBox to add a text field (it will use the parent window if you pass one in to the high level API call, otherwise it will use a dedicated UIWindow like your workaround), but so far it's been working fine for me in both scenarios - I haven't been able to reproduce the problem at all.

I'm testing with SDL's testmessage code plus that change, on an iOS 12.2 Simulator as well as on my iPhone running iOS 12.3.
Comment 5 Alex Szpakowski 2019-06-12 21:54:47 UTC
Ah, I lied... I can seem to reproduce it, I was just stopping before it showed the message box which used a parent window. My bad :)
Comment 6 Alex Szpakowski 2019-06-12 22:23:18 UTC
For now I've removed that didAddSubview override code, doing so fixed it for me: https://hg.libsdl.org/SDL/rev/afe3c46cc37e

I don't understand how that didAddSubview code was supposed to work, and more importantly I don't understand what problem it was supposed to solve exactly. Touch and simulated mouse events and their reported coordinates still work perfectly for me after removing it (tested with some SDL_Render-based code which uses SDL's Metal rendering backend for drawing).

@Sam, is there something that needs to be fixed in a different way after removing the above code? The comment in that code talks about Metal views not responding to touches, but SDL-created Metal views inherit from SDL_uikitview which handles touch events.

If the comment is talking about some custom view added by a user, I believe they can pass through touch event handling to SDL's own view. I also have a patch floating around to allow users to create SDL's metal views directly via new APIs. Or if none of those options are applicable maybe we can move the touch event handling code to the view controller instead of the view?
Comment 7 Dominik Reichardt 2019-06-12 22:27:56 UTC
Thanks for fixing this and confirming that I didn't mess up after all. I just am without my mac for a week so I cannot test it on my end!
Comment 8 Dominik Reichardt 2019-06-12 22:31:31 UTC
Sam's code did fix other problems I and others had with touch not working in our app. See https://discourse.libsdl.org/t/touch-mouse-broken-on-ios/26139/2
Comment 9 Alex Szpakowski 2019-06-12 22:34:53 UTC
Interesting. Touch is working 100% fine for me in my tests. Was there ever a repro project for touch breaking? I wonder what the important difference is between my test projects and apps where it breaks, assuming it's not been fixed by some other change in between then and now.
Comment 10 Dominik Reichardt 2019-06-12 23:07:37 UTC
Too bad I can't test right now but you can test with Exult for iOS https://github.com/litchie/exult-ios (xcode project file is in the iOS subfolder and in there you need to replace the contents of the SDL2 folder with SDL2 hg).
Even though to play the Ultima VII you need the game files, it's enough to test wether touch is now working. The start screen will tell you that you need the game files but a touch should launch safari with our documentation. This did not work without Sam's changeset.
Comment 11 Alex Szpakowski 2019-06-12 23:17:43 UTC
I ran it with the latest SDL code from hg, and tapping the screen opened the sourceforge page in Safari for me.
Comment 12 Dominik Reichardt 2019-06-12 23:26:36 UTC
Hmm, something else fixed it then, I guess ;)
Comment 13 Alex Szpakowski 2019-06-12 23:34:36 UTC
I haven't looked at the codebase at all yet, but is it possible it only breaks at some point after the initial screen, when the game's assets are loaded properly (due to a different UIWindow configuration or something)?
Comment 14 Sam Lantinga 2019-06-12 23:44:10 UTC
I think this fixed it, thanks!
https://hg.libsdl.org/SDL/rev/cbd7a9f0a05e
Comment 15 Sam Lantinga 2019-06-12 23:47:15 UTC
Whoops, never mind...
Comment 16 Sam Lantinga 2019-06-12 23:48:45 UTC
Alex, that comment might be related to a custom Metal view. I'll find out.
Comment 17 Dominik Reichardt 2019-06-20 20:53:36 UTC
Returned and got hg and everything works for me. Issue is resolved on my end. Thanks for looking
Comment 18 Alex Szpakowski 2019-06-20 21:01:03 UTC
Excellent. Thanks for testing!
Comment 19 Dominik Reichardt 2019-06-21 14:42:59 UTC
Btw, I just did a bisect and indeed Sam's changes in https://hg.libsdl.org/SDL/rev/cbd7a9f0a05e were fixing the touch issue without breaking the UIAlertController Text.