Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): prevents post-restore kbd issues by refreshing kbd #10952

Merged
merged 2 commits into from
Apr 19, 2024

Conversation

jahorton
Copy link
Contributor

@jahorton jahorton commented Mar 6, 2024

Fixes #6542.
Fixes #2184.

This works around a longstanding behavior we've noted on certain iOS devices where our keyboards and/or predictive text become "unstable" in one manner or another after the Keyman app has been restored from a backgrounded state. While not the most elegant of solutions (it has user-perceivable effects), simply refreshing the keyboard host page will remove that "instability".

My personal device has always been affected in one way or another when restoring the Keyman app from the background, though the manner has varied at times. Either way, I'm aiming to finally get that fixed.

User Testing

TEST_IOS_APP_RESTORE: Using the Keyman app for iPhone and iPad, verify that the keyboard works correctly after the app is restored from a background state.

  • At a minimum, do the following tests with sil_euro_latin:
    • Use a longpress + select a subkey
    • Use a downward flick
    • Try a multitap on the numeric key to change layers.
    • Try holding a layer-switching key and typing with the temporarily-active layer.
  • If standard gesture visualizations do not show up or operate correctly, FAIL this test.
  • If the output or layer-switches do not act as expected, FAIL this test.

@keymanapp-test-bot keymanapp-test-bot bot added the user-test-missing User tests have not yet been defined for the PR label Mar 6, 2024
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Mar 6, 2024

User Test Results

Test specification and instructions

  • TEST_IOS_APP_RESTORE (PASSED): Tested with the attached PR build (Keyman 17.0.305-beta-test-10952) on an iPhone 13 Mobile device (iOS 17.4) and here is my observation: 1. In the default keyboard, verified that the longpress mend and selecting the sub key is working as expected. 2. Confirmed that the downward flick gesture displayed the special characters.. 3. Verified the multitap on the numeric key to change layers is working correctly. 4. Verified holding a layer-switching key and typing with the temporarily-active layer is working as expected.

Test Artifacts

@keymanapp-test-bot keymanapp-test-bot bot added this to the B17S3 milestone Mar 6, 2024
@darcywong00 darcywong00 modified the milestones: B17S3, B17S4 Mar 16, 2024
@mcdurdin mcdurdin modified the milestones: B17S4, B17S5 Mar 30, 2024
@@ -74,6 +74,14 @@ class KeymanWebViewController: UIViewController {
super.init(nibName: nil, bundle: nil)

_ = view

NotificationCenter.default.addObserver(
forName: UIApplication.willEnterForegroundNotification,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, I don't believe this can affect #11202 - this is an app notification, rather than a notification intended for use by app-extensions (like third-party keyboards).

@jahorton jahorton marked this pull request as ready for review April 11, 2024 04:51
@darcywong00 darcywong00 modified the milestones: B17S5, B17S6 Apr 12, 2024
@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed and removed user-test-missing User tests have not yet been defined for the PR labels Apr 17, 2024
@bharanidharanj
Copy link

Test Results

  • TEST_IOS_APP_RESTORE (PASSED): Tested with the attached PR build (Keyman 17.0.305-beta-test-10952) on an iPhone 13 Mobile device (iOS 17.4) and here is my observation: 1. In the default keyboard, verified that the longpress mend and selecting the sub key is working as expected. 2. Confirmed that the downward flick gesture displayed the special characters.. 3. Verified the multitap on the numeric key to change layers is working correctly. 4. Verified holding a layer-switching key and typing with the temporarily-active layer is working as expected.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Apr 17, 2024
Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a reasonable stop-gap, but it would be good to figure out what is causing the instability rather than just bypassing it, long term.

@jahorton
Copy link
Contributor Author

jahorton commented Apr 19, 2024

After a bit more searching... maybe I've found something this time?

We'd need to test and see if this is being called when our app is restored in this scenarios to be sure it's tied to the behavior that's been seen, of course.

Ref: ionic-team/capacitor#5488 (comment)

The thing we need to be sensitive to is that when a WebView background termination occurs, webViewWebContentProcessDidTerminate() is invoked when the app is coming back into the foreground [...]

Noting other issues from ionic and from react, they've seen cases where the WebView is 100% crashed, showing a blank page. We haven't had that issue, though we also aren't navigating across pages or doing other fancy web-server stuff on the back-end - it's just one page for us... albeit with a WebWorker backend and linked-in JS scripts. There's a fair shot that iOS's WebView is doing its best to restore our page after such a termination but is coming up short.

One concerning thing here, though - these are big teams that are struggling to get this scenario right if this is indeed a match for our circumstances.

@jahorton jahorton merged commit 6167763 into beta Apr 19, 2024
5 checks passed
@jahorton jahorton deleted the fix/ios/refresh-keyboard-on-app-restore branch April 19, 2024 05:43
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 17.0.311-beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants