I am using the Chrome Web NFC API in a web app that runs on Android 13 in Chrome 110 to scan NFC tags. Chrome crashes when I navigate between routes that contain a component with the NDEFReader object and 'ndef.scan' call.
Steps to reproduce
- Navigate to the official web NFC sample content https://googlechrome.github.io/samples/web-nfc/
- Click the 'Scan' button
- Scan an NFC tag
- Now click the 'Scan' button again
- Notice that the browser crashes
Full Code Example: https://github.com/GoogleChrome/samples/blob/gh-pages/web-nfc/index.js
Description of Problem When I navigate to a route containing a component that instantiates the NDEFReader
object and then calls ndef.scan()
, I can scan an NFC tag as expected. However, when I navigate away to the home screen and then back again, the web app crashes when it calls ndef.scan()
.
const ndef = new NDEFReader();
await ndef.scan();
Cases where the web app doesn't crash:
- If I refresh the page in the browser before I call ndef.scan again it will not crash.
- I can call scan as many times as I want as long as I don't physically scan a container before calling scan again.
Chrome Web NFC Documentation: https://developer.chrome.com/articles/nfc/
Update
- Replicable on Android 13, Chrome 110, (last OS security update Feb 5, 2023), Pixel 6
- Replicable on Android 13, Chrome 111, (last OS security update Feb 5, 2023), Pixel 6
- NOT replicable on Android 13, Chrome 110, (last OS security update Aug 5, 2022), Pixel 4
- NOT replicable on Android 13, Chrome 110, (last OS security update Oct 5, 2022), Pixel 4
Bug submitted on the Chromium bug tracker. Upvote it here: https://bugs.chromium.org/p/chromium/issues/detail?id=1424208
As shared in https://bugs.chromium.org/p/chromium/issues/detail?id=1424208#c6, the root issue seems similar to https://b.corp.google.com/issues/238257723 where a new SecurityException is raised on connect().
You can follow fix in progress in the chromium bug tracker: https://bugs.chromium.org/p/chromium/issues/detail?id=1424208
March 27th, 2023 Update: As of Chrome 113.0.5672.0, the issue has been solved.