capawesome-team/capacitor-nfc

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

DD-Factory opened this issue · 3 comments

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   

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

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

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.