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

Issue running the Bluetooth plugin inside my worker #278

Open
AdrianoOP opened this issue Jan 25, 2024 · 3 comments
Open

Issue running the Bluetooth plugin inside my worker #278

AdrianoOP opened this issue Jan 25, 2024 · 3 comments

Comments

@AdrianoOP
Copy link

I'm running into issues with my svelte-native application when I try to instantiate the Bluetooth from the plugin inside my Worker.

I've created a demo project so I could more easily reproduce the issue (https://github.com/AdrianoOP/bluetooth-worker-test). I can make it work perfectly in the main thread, but in the Worker I an error when trying to instantiate the Bluetooth class. Before trying to instantiate the class I'm making sure that permissions have been granted.

Situation happens both with my simulator (Android 13) and cellphone (Android 11)

const communicator = new Bluetooth(); // throws the error below

Error: Trying to link invalid 'this' to a Java object Error: Trying to link invalid 'this' to a Java object
      at new ScanCallBackImpl (file: app/webpack:/bluetooth-worker-test/node_modules/@nativescript-community/ble/index.android.js:466:0)
      at new Bluetooth (file: app/webpack:/bluetooth-worker-test/node_modules/@nativescript-community/ble/index.android.js:1004:0)
      at handleScanMessage (file: app/webpack:/bluetooth-worker-test/app/bluetooth-worker.ts:25:23)
      at globalThis.onmessage (file: app/webpack:/bluetooth-worker-test/app/bluetooth-worker.ts:10:18)

At the moment I suspect the issue is somewhere inside this function:

function initScanCallback() {

My package.json files:
package.json
package-lock.json

@farfromrefug
Copy link
Member

@AdrianoOP thanks for opening an issue. will help tracking it. I am sorry I did not have time to look at it. will br able to so it next week. would that br good with you ?

@AdrianoOP
Copy link
Author

@farfromrefug no worries. I thought could a good idea to open the issue, maybe someone has already seen it.

Sure, whenever you can... I'll keep studying it.

@AdrianoOP
Copy link
Author

@farfromrefug as we were discussing in the discord community, it seems it is an issue related to the android package.

There is a PR opened for that, but while it is not merged an work around can be using the build related to the PR (https://github.com/NativeScript/android/actions/runs/7234213102). You just need to unzip and add it replacing the content inside /platform/android

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants