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(web): restores compat with older Android devices 🐵 #9943

Merged
merged 4 commits into from
Nov 14, 2023

Conversation

jahorton
Copy link
Contributor

@jahorton jahorton commented Nov 6, 2023

Fixes #9443.

Turns out that the es6-shim polyfill doesn't actually polyfill quite everything we want:

  • Object.values, Object.entries - requires Chrome 54. Fortunately, it's also very easy to workaround with minimal code restructuring.
  • Array.includes: Chrome 47.
  • DOMRect with constructor: Chrome 61.
    • This one in particular surprised me, given getBoundingClientRect goes as far back as Chrome 18; the gesture engine has components built on this method in particular.

Also disables keepNames in the lm-worker's es-build config, as noted here: #9943 (comment)

@keymanapp-test-bot skip

this.right = x + width;
};

// https://stackoverflow.com/questions/53308396/how-to-polyfill-array-prototype-includes-for-ie8
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// https://stackoverflow.com/questions/53308396/how-to-polyfill-array-prototype-includes-for-ie8
// https://stackoverflow.com/questions/53308396/how-to-polyfill-array-prototype-includes-for-ie8
// Needed until Chrome 47

Array.prototype.includes = function(search){
return !!~this.indexOf(search);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Is there any syntax required for this polyfill to work with KeymanWeb's ES Modules?

echo "Copying es6-shim polyfill"
cp "$KEYMAN_ROOT/node_modules/es6-shim/es6-shim.min.js" "$ENGINE_ASSETS/es6-shim.min.js"

If this is the only KeymanWeb "asset" not copied from KeymanWeb, I'd probably add a comment about "other-polyfills.js" not needing to be copied.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

other-polyfills.js is hand-maintained, not being copied from a Node package. The only "copying" done here was copying the Array.prototype.includes polyfill used by the lm-worker into other-polyfills.js.

@darcywong00
Copy link
Contributor

Will this fix #9561?

@jahorton
Copy link
Contributor Author

jahorton commented Nov 6, 2023

Will this fix #9561?

I did nothing to target #9561, but it didn't show up, even when I tried looking for it a bit. It has been noted to be "on again", "off again" in some sense... I'll try to keep an eye out for the issue arising again and do a similar investigation if and when it does occur.

... I suppose I could try creating an alt-repo, checking out the version-tag in the report, and locally rebuilding in a repo attempt. Maybe it'll turn something up quickly.

@jahorton
Copy link
Contributor Author

jahorton commented Nov 6, 2023

... of course I didn't see it - I've been doing --debug Android builds, all of which bypass minification.

Manually editing the --debug build to use KMW's minified release products - yep, there's the error. Gives me something to chase.

@@ -34,7 +34,7 @@ if(MINIFY) {
sourcemap: 'external',
sourcesContent: DEBUG,
minify: true,
keepNames: true,
keepNames: false, // Do NOT enable - will break under Android 5.0 / Chrome 35 environments!
Copy link
Contributor Author

@jahorton jahorton Nov 7, 2023

Choose a reason for hiding this comment

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

An update thanks to evanw/esbuild#3477 (comment): this is likely a non-issue starting in Chrome 43.

https://caniuse.com/mdn-javascript_builtins_function_name_configurable_true

@mcdurdin
Copy link
Member

Turns out that the es6-shim polyfill doesn't actually polyfill quite everything we want.

Could you update the description to describe the problem in more detail?

Base automatically changed from feat/web/gesture-preview-host to feature-gestures November 14, 2023 08:26
@jahorton jahorton merged commit eefea0d into feature-gestures Nov 14, 2023
18 of 19 checks passed
@jahorton jahorton deleted the fix/web/gestures-old-android-compat branch November 14, 2023 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants