capawesome-team / capacitor-nfc

⚡️ Capacitor plugin for reading and writing NFC tags.
https://capawesome.io/plugins/nfc/
MIT License
72 stars 14 forks source link

bug: Crash when reading an NFC Tag goes wrong on Android device #18

Closed DD-Factory closed 1 year ago

DD-Factory commented 1 year ago

Plugin version: "@capawesome-team/capacitor-nfc": "5.0.1"

Platform(s): Android

Current behavior: When reading an NFC tag by "brushing" the phone on the tag, sometimes the app fully crashes on Android

Expected behavior: App should not crash when a tag reading goes wrong

Steps to reproduce: Pass the phone on the NFC tag so the vibration of the "read" goes off when the phone isn't on the tag anymore

Related code: Exception goes off on line 789 of "Bridge.java" file. It is then caught on line 186 of "NfcPlugin.java", but in my case, on line 188 of "NfcPlugin.java", the "Log.e(TAG, message);" throws a NullPointerException, which isn't caught and makes the app crash.

I tested on my side, and just adding a null check on the message and sending a generic message instead resolves the issue

Other information: Tested on a Samsung Galaxy A32 5G

Capacitor doctor:

Latest Dependencies:       

  @capacitor/cli: 5.0.5    
  @capacitor/core: 5.0.5   
  @capacitor/android: 5.0.5
  @capacitor/ios: 5.0.5    

Installed Dependencies:    

  @capacitor/cli: 5.0.5    
  @capacitor/android: 5.0.0
  @capacitor/core: 5.0.0   
  @capacitor/ios: 5.0.0   
robingenz commented 1 year ago

Thank you for reporting this. I will publish a new version.

robingenz commented 1 year ago

Unfortunately, I could not reproduce the issue. However, I have still added a null check. Please let me know if the problem persists.

DD-Factory commented 1 year ago

I just tested the version and it doesn't crash anymore in this case, thank you ! This does seem device related and I wouldn't be surprised if Samsung's software layer changed the way Exceptions are built.