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

chore(android): enables debugging and inspection of mobile app internal webviews #11215

Merged
merged 3 commits into from
Apr 17, 2024

Conversation

jahorton
Copy link
Contributor

This PR exists to facilitate diagnosis of #11186 when it occurs.

@keymanapp-test-bot skip

@keymanapp-test-bot
Copy link

User Test Results

Test specification and instructions

User tests are not required

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.

Looks good, but I think we should frame this with alpha+beta checks so it doesn't slip into stable

@github-actions github-actions bot added common/ and removed common/ labels Apr 12, 2024

if (
0 != (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)
|| KMManager.getTier(null) != KMManager.Tier.STABLE
Copy link
Contributor Author

Choose a reason for hiding this comment

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

/**
* Extract KMEA tier from versionName. Uses parameter so we can unit test.
* @param versionName String - If not provided, determine tier from
* com.keyman.engine.BuildConfig.KEYMAN_ENGINE_VERSION_NAME
* @return Tier (ALPHA, BETA, STABLE)
*/
public static Tier getTier(String versionName) {
if (versionName == null || versionName.isEmpty()) {
versionName = com.keyman.engine.BuildConfig.KEYMAN_ENGINE_VERSION_NAME;
}

When left null, .getTier uses the current engine version.

@jahorton jahorton requested a review from mcdurdin April 12, 2024 01:22
@github-actions github-actions bot added common/ and removed common/ labels Apr 12, 2024
@github-actions github-actions bot added common/ and removed common/ labels Apr 12, 2024
@jahorton
Copy link
Contributor Author

Just peachy.

For the iOS build:

2024-04-12 11:39:27.842 xcodebuild[1694:28169924]  DVTPortal: Error:
Error Domain=DVTPortalServiceErrorDomain Code=1100 "Your session has expired. Please log in." [...]

For the Android build:

java.lang.NoSuchMethodError: java.lang.NoSuchMethodError: 'void com.keyman.engine.KMKeyboard.setWebContentsDebuggingEnabled(boolean)'
java.lang.NoSuchMethodError: 'void com.keyman.engine.KMKeyboard.setWebContentsDebuggingEnabled(boolean)'

So... apparently that method isn't available when unit testing. Locally testing, simply blocking the method from being reached during such scenarios is enough, so... I just added an appropriate check on the latest commit.

@@ -130,6 +130,12 @@ class KeymanWebViewController: UIViewController {
webView!.backgroundColor = UIColor.clear
webView!.navigationDelegate = self
webView!.scrollView.isScrollEnabled = false

if #available(iOSApplicationExtension 16.4, *) {
if(Version.current.tier != .stable) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Potential improvement: also add check for if local or test; those should be allowed to override .stable, since they're inherently less stable by virtue of being development versions.

I don't think our iOS engine's Version class yet exposes those as flags, though...

@darcywong00 darcywong00 modified the milestones: B17S5, B17S6 Apr 12, 2024
@mcdurdin
Copy link
Member

iOS build failure:

12:14:30   keyman/ios/engine/KMEI/KeymanEngine/Classes/Keyboard/KeymanWebViewController.swift:136:18: error: value of type 'KeymanWebView' has no member 'isInspectable'
12:14:30           webView!.isInspectable = true
12:14:30           ~~~~~~~~ ^~~~~~~~~~~~~

@jahorton
Copy link
Contributor Author

iOS build failure:

12:14:30   keyman/ios/engine/KMEI/KeymanEngine/Classes/Keyboard/KeymanWebViewController.swift:136:18: error: value of type 'KeymanWebView' has no member 'isInspectable'
12:14:30           webView!.isInspectable = true
12:14:30           ~~~~~~~~ ^~~~~~~~~~~~~

I've gone ahead and linked this detail to #10671. For the sake of moving ahead with this task for Android, I think I'll do a quick rebase to split the iOS changes off into their own PR that can await it without blocking the Android changes.

@jahorton jahorton marked this pull request as draft April 17, 2024 02:01
@jahorton jahorton force-pushed the chore/common/enable-webview-debugging branch from 16baa14 to 6f3c5e0 Compare April 17, 2024 02:04
@jahorton jahorton marked this pull request as ready for review April 17, 2024 02:04
@jahorton jahorton changed the title chore(common): enables debugging and inspection of mobile app internal webviews chore(android): enables debugging and inspection of mobile app internal webviews Apr 17, 2024
Co-authored-by: Marc Durdin <marc@durdin.net>
@github-actions github-actions bot added common/ and removed common/ labels Apr 17, 2024
@jahorton jahorton merged commit eaff3a3 into beta Apr 17, 2024
5 checks passed
@jahorton jahorton deleted the chore/common/enable-webview-debugging branch April 17, 2024 08:49
@keyman-server
Copy link
Collaborator

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

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

Successfully merging this pull request may close these issues.

None yet

4 participants