scratchfoundation / scratch-www

Standalone web client for Scratch
https://scratch.mit.edu
BSD 3-Clause "New" or "Revised" License
1.57k stars 826 forks source link

micro:bit - Scratch app not able to connect via Bluetooth with newer Chromebook #8324

Open martinwork opened 2 months ago

martinwork commented 2 months ago

Expected Behavior

Scratch can connect to micro:bit via Bluetooth

Actual Behavior

Scratch fails to connect to micro:bit via Bluetooth.

Tested on Android 14 tablet, multiple Chromebooks with Android 13 and 9.

It works on the Chromebooks with Android 9, but not on any device tested with Android 13 or 14.

We checked Android location is on.

Steps to Reproduce

Explain what someone needs to do in order to see what's described in Actual behavior above

Steps to reproduce the behavior:

  1. Load Scratch app
  2. Click/tap on the extensions button
  3. Click/tap the micro:bit extension
  4. See error

System Details

If the problem occurs in the browser, please provide operating system and browser e.g. Mac OS 10.11.6 Safari 10.0

If using one of the Apps please provide the app version and device details, e.g. Scratch 3.0.57, Android 9 on HP x360 Chromebook

Scratch 3.0.66, Chromebooks with Android 13.

Screenshots If applicable, add screenshots to help explain your problem.

martinwork commented 2 months ago

@cwillisf Am I posting in the right place for this issue and https://github.com/scratchfoundation/scratch-www/issues/8286

martinwork commented 2 months ago

Related: https://scratch.mit.edu/discuss/topic/758905/?page=1#post-7956131

cwillisf commented 2 months ago

Sorry for the trouble! Thanks for providing details. I can't promise when we'll be able to fix this, but knowing that this seems to be related to newer versions of Android should help quite a bit.

Am I posting in the right place

The best place for individual support is the "Contact Us" form on our website. GitHub Issues is a good place to report a software defect or incompatibility. For this issue in particular, I think this is a fine place to post. Thanks!

martinwork commented 2 months ago

Thanks @cwillisf Micro:bit Foundation Help & Support has received multiple enquiries from teachers trying to use Scratch on Chromebooks. Before realising this was probably the right place to post, I sent a message on the "Contact us" form at the end of April.

cwillisf commented 2 months ago

I've tested a number of situations on my end; you can see my results in the table below.

Note that the very first scan causes a permission prompt in all circumstances, and even if the user picks "Allow," that scan will not work correctly. The behavior listed below corresponds to a second scan, after choosing "Allow." We should certainly refine that experience, but I'll track that as a separate issue.

Device Android Version Behavior
Samsung Tablet Android 13 (Samsung One UI) Works correctly
Simulated Android Tablet (AVD) Android 13 Works correctly (AVD)
Simulated Android Tablet (AVD) Android 14 Works correctly (AVD)
Simulated Android Desktop (AVD) Android 13 Works correctly (AVD)
Chromebook Android 13 Does not display CDM

Interestingly, the official Android sample code exhibits the same behavior: it correctly displays the CDM device selection menu except for on my Chromebook.

There are no errors emitted to the logs, so it's not clear to me what's going wrong. More investigation needed.

@martinwork, are you aware of any application that can connect to a micro:bit on Android 13 or higher while running on a Chromebook? Even without source code, I could check for differences in our permissions requests and such.

cwillisf commented 2 months ago

It's worth noting that none of this behavior seems specific to micro:bit -- other BT and BLE extensions are affected as well.

martinwork commented 2 months ago

@cwillisf Thanks for testing.

@martinwork, are you aware of any application that can connect to a micro:bit on Android 13 or higher while running on a Chromebook? Even without source code, I could check for differences in our permissions requests and such.

No. I must see if I can get access to a recent Chromebook. The example video I have seen did not produce the device selection menu, so matches what you see.

It's worth noting that none of this behavior seems specific to micro:bit -- other BT and BLE extensions are affected as well.

Thanks for that!

After more testing with my Samsung Android 14 tablet, I am able to connect Scratch to micro:bit. Scratch fails to connect if the micro:bit had been paired before the scratch-microbit hex was transferred. In that case I see "Choose a device to be managed by Scratch", but then "Oops, looks like something went wrong.", or it hangs on connecting. It's fine after the micro:bit is unpaired.

cwillisf commented 2 months ago

Scratch fails to connect if the micro:bit had been paired before the scratch-microbit hex was transferred.

Oh, interesting! I'm not sure we'll be able to do anything about that, but it's worth a look next time I'm in there. Thanks!

martinwork commented 1 month ago

@cwillisf Yes, I fell foul of the pairing issue on my PC yesterday, despite knowing about it, and it being mentioned in the Foundation's guide under Troubleshooting! https://support.microbit.org/en/support/solutions/articles/19000026080-using-the-micro-bit-with-scratch

I'm not sure what the Bluetooth error is in other systems, but in iOS, there's a specific error code: something like "Peer removed pairing information".

I suppose it's difficult to customise or expand the Oops message to include a clue about what actually went wrong?