Conversation
getTag() reports the missing session through the callback but then falls
through to the shared `callback(@[[NSNull null], rnTag])` at the end of the
branch, so the callback runs twice for a single call.
On the old architecture the second invocation was silently ignored. Under
the New Architecture's TurboModule interop it is fatal: the callback is
wrapped in a one-shot guard and the second call trips a glog CHECK
("callback arg cannot be called more than once"), aborting the process.
This is easy to hit in practice, because getTag() is a natural thing to
call right after a scan is cancelled or the session has already closed.
Fixes revtel#833
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #833.
The bug
getTag()handles the no-session case by invoking the callback with an error, but does not return. Execution continues past theif (tagSession != nil)block to the shared success callback at the end:ndefTagis stillnilon that path, so the secondcallback(...)always runs. OnegetTag()call invokes its callback twice.Why it matters now
On the old architecture the extra invocation was silently dropped. Under the New Architecture's TurboModule interop the callback is wrapped in a one-shot guard, and the second call trips a glog
CHECK:which aborts the process (SIGABRT), rather than throwing something catchable in JS.
It is easy to reach:
getTag()right after a scan is cancelled, or after the session has already closed, takes the no-session branch every time.The fix
One line.
returnafter the error callback, matching how the other early-exit paths in this method already behave.I have been running this patched into
3.17.2in production for several weeks and it removes the crash. The same missingreturnis present on the v4 branch inios/NfcManager.mm, if you would like me to open a matching PR there.