fix(ios): load host page, keyboards through a consistent WKURLSchemeHandler#16136
fix(ios): load host page, keyboards through a consistent WKURLSchemeHandler#16136jahorton wants to merge 1 commit into
Conversation
User Test ResultsTest specification and instructions
Results TemplateTest Artifacts |
mcdurdin
left a comment
There was a problem hiding this comment.
I like where this is going, some feedback and thoughts on how to tighten it up.
| sourcePath = addDelimiter(sourcePath); | ||
| this.sourcePath = sourcePath; | ||
| this.protocol = sourcePath.replace(/(.{3,5}:)(.*)/,'$1'); | ||
| this.protocol = sourceURL.protocol; |
There was a problem hiding this comment.
Sometimes a little bit of cleanup just makes things so much prettier
| } | ||
|
|
||
| updateFromOptions(pathSpec: Required<PathOptionSpec>) { | ||
| const _rootPath = this.sourcePath.replace(/(https?:\/\/)([^\/]*)(.*)/,'$1$2/'); |
There was a problem hiding this comment.
Not exactly sure what it's doing, and I didn't need to change it, so I decided to leave this be.
|
|
||
| // Local function to convert relative to absolute URLs | ||
| // with respect to the source path, server root and protocol | ||
| fixPath(p: string) { |
There was a problem hiding this comment.
Could this whole function be replaced with new URL(p, this.sourcePath)?
There was a problem hiding this comment.
I'd want to test that out more thoroughly as its own PR, rather than rolling it in here.
| @@ -36,12 +36,14 @@ | |||
| ``` | |||
| */ | |||
There was a problem hiding this comment.
| */ |
Legacy comment!
| // +1: include the ':' that likely exists | ||
| pathComponent = String(components.path.dropFirst(KeymanWebViewController.SCHEME.count + 1)) | ||
| } | ||
|
|
There was a problem hiding this comment.
I'm confused about this piece of code. Surely pathComponent should never include keyman-engine:? That would be components.scheme?
Also, I think this would be a good place to collapse repeated slashes, both at start of string and beyond, because repeated slashes when building paths is a common bug and I think we can be resilient to it without real penalty.
That also removes the need to do that work in pathConfiguration.ts.
pathComponent = components.path.replacingOccurrences(of: "/+", with: "/", options: .regularExpression)
if pathComponent.hasPrefix("/") {
pathComponent = pathComponent.dropFirst()
}
Something like that?
There was a problem hiding this comment.
This was an earlier attempt to work around issues in which URLs like the following appeared: keyman-engine:/keyman-engine:/kmwosk.css
It didn't work, which led to resolving things in Web engine code - the changes to pathConfiguration.ts, oskView.ts, and visualKeyboard.ts.
Will clean up now.
That also removes the need to do that work in pathConfiguration.ts.
pathComponent = components.path.replacingOccurrences(of: "/+", with: "/", options: .regularExpression) if pathComponent.hasPrefix("/") { pathComponent = pathComponent.dropFirst() }
... about that. If there are repeated leading slashes, URLComponents will consider the 'path' as the host, not a path! For most of our resources, this then results in a nil path, which is very much something we don't want. Some of the changes seen in pathConfiguration.ts were made b/c they're the easiest workaround... or were at the time.
There was a problem hiding this comment.
... and fortunately, the fixes in OSK code resolved the cases that were causing this, so we can still knock the pathConfiguration.ts double-slash handling out!
|
One more thought; can we base this on #16132 so that we are looking at a consolidated fix for both platforms? |
Work is still ongoing there, and there's been at least one force-push to that branch since the quoted comment was posted. I'd have to re-force-push this branch every time a force-push happens there. |
2e9568e to
b9a3c11
Compare
b9a3c11 to
1f99b2d
Compare
…andler This bypasses any need to modify KMW keyboard loading (say, via .fetch), though it does require a number of collateral changes to be made in order for CORS, etc to be satisfied. Build-bot: skip build:ios
Pretty much just what the title says; it's been silently missing this whole time. This doesn't fix iOS keyboard's display by itself, but it is a prerequisite for the full solution offered by #16136. Build-bot: skip build:ios Test-bot: skip
Pretty much just what the title says; it's been silently missing this whole time. This doesn't fix iOS keyboard's display by itself, but it is a prerequisite for the full solution offered by #16136. Build-bot: skip build:ios Test-bot: skip
1f99b2d to
08c2f25
Compare
These changes bypass any need to modify KMW keyboard loading (say, via .fetch), instead forcing all engine files and resources to load via the new scheme/protocol in order to accomplish its goal.
Alternate approaches considered:
file://protocol calls to ping Swift for a file load, then pass the results back via JS call that resolves the associated fetch Promise.Build-bot: skip release:ios,web
User Testing
TEST_IOS:
TEST_WEB:
TEST_WEB_KBD_DOCS: