Skip to content

fix(web): fix error trying to calculate style scaling effects#14684

Merged
ermshiperete merged 2 commits intomasterfrom
fix/web/14108_NaN
Sep 8, 2025
Merged

fix(web): fix error trying to calculate style scaling effects#14684
ermshiperete merged 2 commits intomasterfrom
fix/web/14108_NaN

Conversation

@ermshiperete
Copy link
Copy Markdown
Contributor

@ermshiperete ermshiperete commented Sep 4, 2025

PR #13860 fixed a similar error by adding a check for NaN. However, it missed doing it for layoutWidth and only changed layoutHeight.

This PR adds a similar check to layoutWidth and will thus fix the error we're still seeing in Sentry.

Also add unit tests for both methods.

User Testing

TEST_INUKTITUT_KEYBOARD: Using Keyman for Android, install the inuktitut_pirurvik and verify that no error notifications appear.

Fixes: #14108
Fixes: KEYMAN-WEB-RA

PR #13860 fixed a similar error by adding a check for NaN. However, it
missed doing it for `layoutWidth` and only changed `layoutHeight`. This
PR adds a similar check to `layoutWidth` and will thus fix the error
we're still seeing in Sentry.

Also add unit tests for both methods.

User Testing
============

TEST_INUKTITUT_KEYBOARD: Using Keyman for Android, install the
`inuktitut_pirurvik` and verify that no error notifications appear.

Fixes: #14108
Fixes: [KEYMAN-WEB-RA](https://keyman.sentry.io/issues/6579536471/?referrer=github_integration)
@github-project-automation github-project-automation bot moved this to Todo in Keyman Sep 4, 2025
@keymanapp-test-bot keymanapp-test-bot bot added the user-test-missing User tests have not yet been defined for the PR label Sep 4, 2025
@keymanapp-test-bot keymanapp-test-bot bot added this to the A19S11 milestone Sep 4, 2025
@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 Sep 4, 2025
@ermshiperete ermshiperete marked this pull request as ready for review September 4, 2025 15:30
if (this.usesFixedWidthScaling) {
let baseWidth = this.width;
baseWidth -= this._borderWidth * 2;
baseWidth = (isNaN(baseWidth) || baseWidth < 0) ? 0 : baseWidth;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does get internalHeight() (l.820) have a similar pattern to check?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does a baseWidth of zero actually make sense?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question. @jahorton Do you have any insights on that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this scenario generally reflects when Keyman Engine for Web is still initializing - or perhaps if the hosting WebView has been backgrounded temporarily, before it's fully back in the view hierarchy. If memory serves, the correct values generally come through pretty quickly thereafter.

@Nnyny Nnyny self-assigned this Sep 5, 2025
@Nnyny
Copy link
Copy Markdown
Contributor

Nnyny commented Sep 5, 2025

Test Results

Before testing:
- Install 19.0.113.apk on API 36

  • TEST_INUKTITUT_KEYBOARD (PASSED): notes
  1. Launch Keyman 19.0.113-alpha-test-14684
  2. Dimiss 'Get Started'
  3. Go to 'Settings' > 'Install Keyboard or Dictionary' > 'Install from keyman.com' > search for 'inuktitut_pirurvik'
  4. Install the keyboard
  5. Verify there's no error message and the keyboard is working ok

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Sep 5, 2025
if (this.usesFixedWidthScaling) {
let baseWidth = this.width;
baseWidth -= this._borderWidth * 2;
baseWidth = (isNaN(baseWidth) || baseWidth < 0) ? 0 : baseWidth;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does a baseWidth of zero actually make sense?

The same error could potentially happen in `internalHeight`, so we
add the check for NaN there as well. Addresses code review comments.
it('calculates InternalHeight correctly for number', () => {
const vk = createVisualKeyboard();
vk['_height'] = 100;
assert.equal(vk.internalHeight.val, 88);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jahorton The values we get from internalHeight look wrong since we're subtracting the borders twice. Or is that intentional?

ermshiperete added a commit that referenced this pull request Sep 5, 2025
PR #13860 fixed a similar error by adding a check for NaN. However, it
missed doing it for `layoutWidth` and only changed `layoutHeight`. This
PR adds a similar check to `layoutWidth` and will thus fix the error
we're still seeing in Sentry.

The same error could potentially happen in `internalHeight`, so we
add the check for NaN there as well. Addresses code review comments.

Also add unit tests for all three methods.

# User Testing

TEST_INUKTITUT_KEYBOARD: Using Keyman for Android, install the
`inuktitut_pirurvik` and verify that no error notifications appear.

Fixes: #14108
Fixes: [KEYMAN-WEB-RA](https://keyman.sentry.io/issues/6579536471/?referrer=github_integration)
Cherry-pick-of: #14684
@ermshiperete ermshiperete merged commit e92a82d into master Sep 8, 2025
18 checks passed
@ermshiperete ermshiperete deleted the fix/web/14108_NaN branch September 8, 2025 07:06
@github-project-automation github-project-automation bot moved this from Todo to Done in Keyman Sep 8, 2025
ermshiperete added a commit that referenced this pull request Sep 8, 2025
PR #13860 fixed a similar error by adding a check for NaN. However, it missed doing it for `layoutWidth` and only changed `layoutHeight`. This PR adds a similar check to `layoutWidth` and  `internalHeight` and will thus fix the error we're still seeing in Sentry.

Also add unit tests for all three methods.

Fixes: #14108
Fixes: [KEYMAN-WEB-RA](https://keyman.sentry.io/issues/6579536471/?referrer=github_integration)
Cherry-pick-of: #14684
@keyman-server
Copy link
Copy Markdown
Collaborator

Changes in this pull request will be available for download in Keyman version 19.0.114-alpha

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

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

bug(web): NaN appeared while trying to calculate style scaling effects

6 participants