ionic-framework: bug: Ionic call Keyboard.getResizeMode() on Android throws uncaught error

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

when app start in android the Keyboard.getResizeMode() call from one of the ionic global component that it catched and show runtime error . I read docs of capacitor keyboard and we know that getResizeMode() method is for iOS only . why in android called on app init automatically ?

This is my console error :

result Keyboard.getResizeMode (#71292250)

{
    "message": "not implemented",
    "code": "UNIMPLEMENTED"
}

Also this is screen shots of android version

it’s make my app unuseable with vue-cli in vite version the runtime error not show but console throw excetiopn still fire

Screenshot 2023-05-18 at 4 16 12 PM

And my android Emulator

Screenshot 2023-05-18 at 4 16 40 PM

Expected Behavior

I think if ionic use the Keyboard.getResizeMode() in any components it should check platform first for ignore calling on android and call in iOS only

Steps to Reproduce

  1. Check the global ionic components that using Keyboard.getResizeMode()
  2. make sure the platform checked first and call Keyboard.getResizeMode() only in iOS
  3. Maybe Catche exception in capacitor/keyboard plugin for ignore runtime error even Keyboard.getResizeMode() called in any platform by 3rd Party plugins or components thats not official .

Code Reproduction URL

GitHub starter tab app created with latest ionic cli and ionic vue and capacitor 5 ( But the bug is still with cap 4 too and I think its fire from ionic )

https://github.com/farshidpg/ionic-starter/tree/main

Starter app ionic info

Ionic:

   Ionic CLI       : 7.1.1
   Ionic Framework : @ionic/vue 7.0.7

Capacitor:

   Capacitor CLI      : 5.0.3
   @capacitor/android : 5.0.3
   @capacitor/core    : 5.0.3
   @capacitor/ios     : not installed

Utility:

   cordova-res : 0.15.4
   native-run  : 1.7.2

System:

   NodeJS : v19.6.1
   npm    : 9.5.0
   OS     : macOS Unknown

the problem still get error on app init

Ionic Info


   Ionic CLI       : 7.1.1
   Ionic Framework : @ionic/vue 7.0.7

Capacitor:

   Capacitor CLI      : 4.8.0
   @capacitor/android : 4.8.0
   @capacitor/core    : 4.8.0
   @capacitor/ios     : 4.8.0

Utility:

   cordova-res : 0.15.4
   native-run  : 1.7.2

System:

   NodeJS : v19.6.1
   npm    : 9.5.0
   OS     : macOS



Android SDK : 33

Additional Information

Capacitor keyboard plugin information getresizemode method

https://capacitorjs.com/docs/v4/apis/keyboard#getresizemode

I check my project and I know I don’t use Keyboard.getResizeMode() method manually , I’m sure it’s called globally

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 20 (8 by maintainers)

Commits related to this issue

Most upvoted comments

If you are up for checking another dev-build: 7.0.8-dev.11684444351.1b1ab142

I updated the checks so that the check for platform is first: https://github.com/ionic-team/ionic-framework/commit/b1ab142d3bb0120f42e1004cb66265ce213a40d7. This should cause the behavior to noop for MD or if you are not using the Keyboard plugin from Capacitor.

If that doesn’t work - I can boot up an emulator and do additional testing tomorrow.

Hi everyone,

We released a fix for this as part of the v7.0.9 release today. Thanks to everyone who helped test the fix!

v7.0.9 changelog: https://github.com/ionic-team/ionic-framework/releases/tag/v7.0.9

It is still subject to the team’s review, you can track the pull request here: https://github.com/ionic-team/ionic-framework/pull/27514

Once merged, it will be available on the next week’s patch release (we try to release weekly).

Happy to help & thanks for the quick testing and verification 🎉

NPM package resolution can be difficult. The nightly- build is a different output than the provided dev build.

You can try removing the leading ^ in your package.json:

{
  "name": "starter",
  "private": true,
  "version": "0.0.1",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vue-tsc && vite build",
    "preview": "vite preview",
    "test:e2e": "cypress run",
    "test:unit": "vitest",
    "lint": "eslint"
  },
  "dependencies": {
    "@capacitor/android": "5.0.3",
    "@capacitor/app": "5.0.2",
    "@capacitor/core": "5.0.3",
    "@capacitor/haptics": "5.0.2",
    "@capacitor/keyboard": "5.0.2",
    "@capacitor/status-bar": "5.0.2",
    "@ionic/vue": "7.0.8-dev.11684444351.1b1ab142",
    "@ionic/vue-router": "7.0.8-dev.11684444351.1b1ab142",
    "ionicons": "^7.0.0",
    "vue": "^3.2.45",
    "vue-router": "^4.1.6"
  },
  "devDependencies": {
    "@capacitor/cli": "5.0.3",
    "@vitejs/plugin-legacy": "^4.0.2",
    "@vitejs/plugin-vue": "^4.0.0",
    "@vue/eslint-config-typescript": "^11.0.2",
    "@vue/test-utils": "^2.3.0",
    "cypress": "^12.7.0",
    "eslint": "^8.35.0",
    "eslint-plugin-vue": "^9.9.0",
    "jsdom": "^21.1.0",
    "typescript": "^4.9.3",
    "vite": "^4.1.0",
    "vitest": "^0.29.2",
    "vue-tsc": "^1.0.24"
  },
  "description": "An Ionic project"
}

If npm ls @ionic/core continues to resolve the incorrect version, I can provide an updated fork to your original repo for verification.

i tried 7.0.8 and the error is still there.

any reason why this wasn’t included in the patch release? from what i see this throws an error on every android device.

@farshidpg can you remove the explicit @ionic/core dependency and run npm ls @ionic/core?

The expected output should be:

starter@0.0.1 /Users/sean/Documents/ionic/issues/ionic-starter
└─┬ @ionic/vue@7.0.8-dev.11684444351.1b1ab142
  └── @ionic/core@7.0.8-dev.11684444351.1b1ab142

Can you also confirm you are re-running npm run build and npx cap copy android after updating the dependency?

With the latest dev-build on the reproduction, I do not receive errors in the console on an emulator.

@farshidpg thanks for testing so quickly!

I believe the problem is related to that change as well, but with the shared keyboard logic we encapsulate.

For reference, this is what the dev-build changed: https://github.com/ionic-team/ionic-framework/commit/e9b8b2d789d9466697fd0ad4e3cc9ed7b65aacc1

I’ll need to do a little more discovery to narrow where else the resize mode is being called (or if the platform check is not sufficient enough for this use case).

Edit: I actually see where my logic is flawed - an engine can be defined on md… let me rework that.

Hello everyone 👋

Could someone test with this dev-build and let me know if they run into any issues?

7.0.8-dev.11684441614.1e9b8b2d

any body can help with this i have same issue