keymanapp / keymanapp/keyman

bug(ios): System keyboard crashes on orientation change in Safari address bar

Open
#2,300 6 comments 0 reactions 0 assignees View on GitHub
bug ios/
Dominant language
Pascal
Stars
534
Forks
143
Avg merge
2d 10h
Merged PRs (30d)
113

Description

**Describe the bug**
The title just about covers it - our keyboard app extension generally crashes whenever the device's orientation is changed within Safari when giving input to the address/search bar. There are a few interesting details worth note, though:

- Using the system keyboard with webpage content? No problem! Just avoid the address bar.
- The keyboard actually rotates first, crashing almost immediately after the rotation completes.
- On the crash, iOS automatically causes the extension to reload the keyboard, initializing a new instance of `KeyboardViewController`.
- This may be noteworthy, as most normal types of crashes result in the extension being "kicked out" and replaced by a different system keyboard.
- This results in a fairly poor user experience, as there's quite a bit of startup delay required for the keyboard to reload. (Granted, the user likely won't be constantly rotating the keyboard as they type...)

**To Reproduce**
Steps to reproduce the behavior:
1. Set Keyman as an allowed system keyboard
2. Open Safari and select the address bar, summoning a keyboard.
3. Activate Keyman
4. Change orientation

**Expected behavior**
Identical rotation behavior to what occurs within the Keyman app.

---

**iPhone/iPad/Android (please complete the following information):**
- Device: any iOS device (tested with iPhone SE on 13.1, simulated iPhone SE 13.1, simulated iPhone X 13.1)
- OS: iOS 13.1 (since it's current)
- Keyman version: 12.0.53 (real iPhone SE), 13.0.16 alpha (Simulator devices)
- Target application: Safari (at minimum)

Does not occur in Notes app, Keyman app, or Google Docs.

**Additional context**
After some debugging, I've found that the final log message before the new `KeyboardViewController` instance is created is as follows:

```
2019-11-06 15:45:09.060788+0700 SWKeyboard[9037:512001] Failed to inherit CoreMedia permissions from 9034: (null)
```

Note that the `9034` part appears to be randomized on each build; the "failed to inherit CoreMedia" bit is the significant part. Unfortunately, all occurrences of this error string I can find when searching are regarding other scenarios or errors and have "solutions" that don't apply within this scenario.

When I add logging messages to the keyboard rotation handlers, I can see that the crash happens almost immediately after the final constraint adjustment through `KeyboardViewController.updateViewConstraints()` is handled. Preventing a reset of the banner's image resource does not prevent the issue.

Finally, it may be worth noting that this may be due to an interaction with our keyboard's architecture:
- Within Safari...
- We open a keyboard App Extension from Keyman...
- Which itself is embedding a `WKWebView` that utilizes Safari.

Alternatively, possibly worth investigating - in this situation, we're giving input to a UI element that may be hosted within a `UINavigationBar`. I'm having trouble finding other apps with a similar setup. While the Google Maps app may be a candidate, it doesn't trigger the error - and the styling's just different enough that I doubt it uses a `UINavigationBar` implementation for the search bar anyway.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.