-
Notifications
You must be signed in to change notification settings - Fork 191
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
Service Worker support for WebBluetooth #422
Comments
@reillyeon @dougt for thoughts. |
Hi that would be nice. We use website as store application and connect barcode scanners as keyboard right now. We are experimenting with WebBluetooth on barcode scanner and weight scales (for parcels). Problem is that you have to reconnect device each page refresh / GET / POST. Each employee has his tablet and scanner. I think service worker with persistent bluetooth connections would really help. |
@PavelCibulka as an interim step Chrome is working on implementing support for retaining access to a device across navigations. That is still not quite as convenient as moving the connection management into a Service Worker but should help resolve the issue you are having. Follow along on issue 577953 for progress. |
Could they also look at implementing |
Just to add my thoughts to this - I'm currently working on a hackable smartwatch - allowing users to keep a connection open in the background and communicate with their device would be a huge benefit. |
TL;DR: Web Bluetooth support in service workers is complicated and has many questions that need to be answered before it can be considered. Discussion on these questions is welcome to generate ideas for how to address them. There are some questions that need to be answered before Web Bluetooth support is able to be considered in service workers. These are just some that that pop into my head at the moment:
I do have some ideas to address or partially address some of these questions. It would be great to hear any thoughts on these or other ideas or questions that should be asked.
Again, these are just some ideas that I have to address some of these concerns, and I welcome any other thoughts on them. Most of these questions also apply to WebUSB, Web Serial, and WebHID support in service workers. |
I have a use case for being able to update my BT device over BT while it's not in active use. This would also be perfect to do in a service worker. In terms of how this should be done. I think there are quite good practice to be found on phones already. You get an initial question of whether or not you want to give the permission. Then after a while you get a notification that says that the app has been using your BT/GPS/whatever behind the scenes and whether or not you want to keep allowing that. From that point on ( I guess with some time limit ) you won't be bugged with notifications. |
We have a use case where the users device is used to open a door from a wall mounted reader via bluetooth. In this case, close proximity is required for background usage. Perhaps close proximity is a reasonable security requirement for background usage, if that's even feasible? |
It would be great, you could realize a (COVID-19) "contact tracing" app as a webapp. |
Technically, it would be very interesting if we could do so given the API capabilities and other applications. There would be significant privacy concerns to work through first. This isn't a near term goal. Practically, to address the pandemic, it is more appropriate to have operating systems offer this service in a power and privacy efficient way. There is work underway to do this: https://www.blog.google/inside-google/company-announcements/apple-and-google-partner-covid-19-contact-tracing-technology/ |
Is there any progress in this feature? |
So imagine the scenario, where delivery orders are sent in and you have to print order labels to a bluetooth thermal printer. The situations I am considering are:
(real scenario is a little bit more complex involving multiple devices, multiple receipt printers and a label printer) |
Working within the current limitations I would recommend using the push notification to alert the user that they need to switch back to the application in order to print a new receipt. I recognize this isn't ideal. |
We have another use case. We only need to know which BT devices are near. No connection is needed. Our goal is to start macros if specific IDs are close by. |
I'd like to expand on the scenario above, as I think it's a good explanation about scenarios that Web-Bluetooth can't solve which native APIs can. Scenario There are two (or more) printers:
Association Printing Online Order The ideal solution would be to use PUSH API to wake a service worker, which can immediately connect to the bluetooth printers and print. This way if the device is idle or a user is using another application the printing process can continue uninterrupted. Note that this entire process is possible within native apps, but is not possible on web-bluetooth. I realize there are possible privacy/security concerns, but I think a good general stance is if you can do it on native, you should be able to do it on the web. If the privacy/security risks are too big to be mitigated by any process then that functionality should also be removed from native. |
I can't understand why I saw I have a web app need to access my company's product. The web app is able to access my device with |
It'd be nice to have a way to bypass the slowing/pausing of unfocused tab. If you have a bluetooth device that say, needs data read/written to every 100ms, there might be an issue if the user goes away to look at something else. |
I'm absolutely against of Service Workers (which means malware persistence and background activation), and I'm especially against of allowing Service Workers to access Bluetooth, USB, MIDI and so on. Without proper explicit user-vetting of every action with such dangerous APIs they can hecome a privacy and security threat. User-vetting of every action by a service worker (and of every event sent to the service worker by browser!) defeats the purpose of Service Workers. And don't tell me that modern users won't install malware if they are told "install malware or go away from my website" by a powerful and essential website. |
You have to considere, that websites are replacing most of the classical EXE applications. So web browset need service workers for manage label printers, barcode scanners, scales etc. |
@KOLANICH I feel like service worker access is definately tricky. I feel like dedicated slightly OT but, the entire browser security model is tricky, vendors try their best to lock off functionality (mostly for security, sometimes not), but you end up in a weird situation where sometimes users can't upload files from their cloud drive, but you can download ransomware with two clicks. |
offtop
pdf.js is that it is written in a memory-safe language. Impls in Java, .Net or Rust should do the job of rendering pdf better. |
@KOLANICH What is important is maintenance. It is more efficient to mantain single website than update software on 1000+ devices. Also website development is much faster than EXE development. |
offtop
Windows is a pretty uniform platform. For software distribution one can use https://learn.microsoft.com/en-us/windows/package-manager/ . I admit that using browsers is an easy way for onboarding new users because one can put a link to the webapp into a webpage. But for anything more serious than just a demo standalone apps are more optimal. |
OT@KOLANICH If Windows was such a unified platform with easy software distribution (would you like my laughter in .msi, NSIS, InnoSetup, WiX .exe, Squirrel, bespoke .exe installer, AppX, AppV, MSIX, XAP, MSStore, ClickOnce, .cab file, or portable .zip format) there'd be no need for an entire industry of products that exist soely to take the applications you have and run them on the infrastructure you have.Making a web app for certain devices IMHO, the future and how everything should be. It's so much easier to just send a link to a webpage that updates every time you refresh. Plus, web pages are much more isolated, (i.e. a badly made installer cant munge the registry), and there's no residual files when you uninstall an app. Also, if it works in a web browser, it works on Windows, Mac, Android, ChromeOS, etc. You don't have to haul an old PC out of storage because the manufacturer only shipped an EXE that only works on Windows 7. Everyone else on the email thread can accept my sincere apologies. |
Please stay on topic. To answer the original question:
Not throttling pages with active Bluetooth connections is tracked in a Chromium issue and is relatively straightforward to implement, as we recently made a similar change for active serial connections. |
An issue to track the adding ServiceWorker support to WebBluetooth.
Things to think about:
-Should it ask permission again every time or just once with option to allow again until revoked?
The text was updated successfully, but these errors were encountered: