# \_checkForConnectedDevices throw "TypeError: Illegal invocation"

**URL:** <https://forum.babylonjs.com/t/checkforconnecteddevices-throw-typeerror-illegal-invocation/32722>\
**Category:** Bugs\
**Created:** [August 2, 2022, 6:57pm UTC](https://forum.babylonjs.com/t/checkforconnecteddevices-throw-typeerror-illegal-invocation/32722 "2022-08-02T18:57:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel-rabe](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/daniel-rabe/32/26076_2.png) [@daniel-rabe](https://forum.babylonjs.com/u/daniel-rabe)\
**Post date:** [August 2, 2022, 6:57pm UTC](https://forum.babylonjs.com/t/checkforconnecteddevices-throw-typeerror-illegal-invocation/32722/1 "2022-08-02T18:57:38Z")

</div>

We see quite often this error on `new Scene` in our tracking tool, but we can not reproduce it.

```auto
TypeError: Illegal invocation
  at _checkForConnectedDevices(webpack://egr-onlineplanner/./node_modules/@babylonjs/core/DeviceInput/InputDevices/webDeviceInputSystem.js:177:38)
  at _enableEvents(webpack://egr-onlineplanner/./node_modules/@babylonjs/core/DeviceInput/InputDevices/webDeviceInputSystem.js:143:18)
  at new e(webpack://egr-onlineplanner/./node_modules/@babylonjs/core/DeviceInput/InputDevices/webDeviceInputSystem.js:36:14)
  at new e(webpack://egr-onlineplanner/./node_modules/@babylonjs/core/DeviceInput/InputDevices/internalDeviceSourceManager.js:50:39)
  at new e(webpack://egr-onlineplanner/./node_modules/@babylonjs/core/DeviceInput/InputDevices/deviceSourceManager.js:15:49)
  at attachControl(webpack://egr-onlineplanner/./node_modules/@babylonjs/core/Inputs/scene.inputManager.js:435:37)
  at attachControl(webpack://egr-onlineplanner/./node_modules/@babylonjs/core/scene.js:1522:28)
  at new t(webpack://egr-onlineplanner/./node_modules/@babylonjs/core/scene.js:665:19)

```

- Browser is always Chrome (different versions 79, 80, 96, 97, 98)
- OS always Windows 10
- atm we use babylonjs/core 5.0.0-beta.9 but we saw the error already in our previous builds with 5.0.0-alpha.45
- because i don’t see any changes to the `_checkForConnectedDevices` callback in babylonjs/core latest version i guess the error will continue to occure when we update

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [August 2, 2022, 8:12pm UTC](https://forum.babylonjs.com/t/checkforconnecteddevices-throw-typeerror-illegal-invocation/32722/2 "2022-08-02T20:12:31Z")

</div>

cc @PolygonalSun

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [August 2, 2022, 8:26pm UTC](https://forum.babylonjs.com/t/checkforconnecteddevices-throw-typeerror-illegal-invocation/32722/3 "2022-08-02T20:26:14Z")

</div>

@daniel-rabe can you repro in the playground ? I am wondering if it is related to one functionality in use in your code, or if it is more related to some environments. Would be awesome if you have a repro 🙂

---

<div class="post-metadata">

**Author:** ![cyberphil](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cyberphil/32/28399_2.png) [@cyberphil](https://forum.babylonjs.com/u/cyberphil)\
**Post date:** [December 7, 2022, 8:32am UTC](https://forum.babylonjs.com/t/checkforconnecteddevices-throw-typeerror-illegal-invocation/32722/4 "2022-12-07T08:32:39Z")

</div>

unfortunately we cannot reproduce it.

var gamepads = navigator.getGamepads();  
seems to throw the error on creating the scene

It occurs on different platforms windows/mac/ios  
It seems to be always chrome browser, but affects only a really small part of our sessions.

In the web you find some threads about navigator occasionally looses its context.  
[You May Not Know Beacon](https://xgwang.me/posts/you-may-not-know-beacon/) the article is about referencing navigator functions.  
but maybe it is the same issue here.

In firefox we really rarely get:  
Navigator.getGamepads: Document’s Permission Policy does not allow calling getGamepads() from this context.

Our production version is currently 5.15.1

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [December 7, 2022, 5:34pm UTC](https://forum.babylonjs.com/t/checkforconnecteddevices-throw-typeerror-illegal-invocation/32722/6 "2022-12-07T17:34:10Z")

</div>

Unfortunately there is not much we can do from the babylon side on this one ☹

I wonder how hard it would be for you to get more data to share with the Chromium team as it sounds like a bug on their side ?
