Closed Bug 1055960 Opened 11 years ago Closed 11 years ago

B2G NFC: onpeerlost won't be called if peerready is reset

Categories

(Firefox OS Graveyard :: NFC, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(blocking-b2g:2.1+, firefox33 wontfix, firefox34 fixed, firefox35 fixed, b2g-v2.1 fixed, b2g-v2.2 fixed)

RESOLVED FIXED
2.1 S4 (12sep)
blocking-b2g 2.1+
Tracking Status
firefox33 --- wontfix
firefox34 --- fixed
firefox35 --- fixed
b2g-v2.1 --- fixed
b2g-v2.2 --- fixed

People

(Reporter: allstars.chh, Assigned: allstars.chh)

References

Details

(Keywords: regression, Whiteboard: [p=2])

Attachments

(3 files, 2 obsolete files)

By definition onpeerlost should be called when the peer got in the peerready is lost. So considering following case: nfc.onpeerready = function () { ... nfc.onpeeready = null; }; nfc.onpeerlost = function () { }; inside onpeerready callback, it reset the handler to null so onpeerlost won't be fired.
Whiteboard: [good first bug]
Summary: B2G NFC: onpeer lost won't be called if peerready is reset → B2G NFC: onpeerlost won't be called if peerready is reset
[Blocking Requested - why for this release]: regression from Bug 1043186
blocking-b2g: --- → 2.1?
Assignee: nobody → allstars.chh
Whiteboard: [good first bug]
I'll fix three problems in this bug 1. Comment 0 2. only needs notifyUserAcceptedP2P to trigger onpeerready. 3. notifyPeerLost will check IsPeerReadyCalled, however it's buggy for if the 1st time onpeerready/onpeerlost both have been called, in the 2nd tech-discovered, we didn't do the Swipe (not calling notifyUserAcceptedP2P), and in the 2nd tech-lost, onpeerlost will still be called.
Comment on attachment 8481231 [details] [diff] [review] Patch Review of attachment 8481231 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/nfc/gonk/Nfc.js @@ +226,5 @@ > + > + // For peerlost, the message is delievered to the target which > + // onpeerready has been called before. > + this.notifyPeerEvent(this.currentPeer, NFC.NFC_PEER_EVENT_LOST, sessionToken); > + this.currentPeer = null; this.currentPeer should be also set to null if the target is killed.
- remove this.currentPee in removeTarget - remove function isPeerReadyTarget
Attachment #8481231 - Attachment is obsolete: true
Attachment #8482061 - Flags: review?(dlee)
Comment on attachment 8482061 [details] [diff] [review] Part 1: fix onpeerlost. Review of attachment 8482061 [details] [diff] [review]: ----------------------------------------------------------------- Looks good, thanks ::: dom/nfc/gonk/Nfc.js @@ +176,5 @@ > }, > > + notifyPeerEvent: function notifyPeerEvent(target, event, sessionToken) { > + if (!target) { > + dump("invalid target"); debug
Attachment #8482061 - Flags: review?(dlee) → review+
(In reply to Dimi Lee[:dimi][:dlee] from comment #6) > > + notifyPeerEvent: function notifyPeerEvent(target, event, sessionToken) { > > + if (!target) { > > + dump("invalid target"); > > debug It is my intention to use dump since callers have checked 'target' before calling this. However if target is still null/undefined when this function is called, error will be thrown.
(In reply to Yoshi Huang[:allstars.chh] from comment #7) > (In reply to Dimi Lee[:dimi][:dlee] from comment #6) > > > + notifyPeerEvent: function notifyPeerEvent(target, event, sessionToken) { > > > + if (!target) { > > > + dump("invalid target"); > > > > debug > > It is my intention to use dump since callers have checked 'target' before > calling this. > However if target is still null/undefined when this function is called, > error will be thrown. ok!
Attachment #8482061 - Attachment description: Patch v2. → Part 1: fix onpeerlost.
When fixing removePeerTarget also found targetsByRequestId also has this problem
Attachment #8482102 - Flags: review?(dlee)
Attachment #8482102 - Flags: review?(dlee) → review+
add checkin-needed for b2g-inbound is close.
Keywords: checkin-needed
blocking-b2g: 2.1? → 2.1+
Keywords: regression
Blocks: 1043186
Comment on attachment 8482653 [details] [diff] [review] Part 3: fix tests case. Review of attachment 8482653 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/nfc/tests/marionette/test_nfc_error_messages.js @@ +101,5 @@ > nfc.onpeerready = null; > deferred.resolve(); > }; > > + nfc.notifyUserAcceptedP2P(MANIFEST_URL); Just curious about removing checkP2PRegistration here because of |this.currentPeerAppId| is removed so we don't have to call checkP2PRegistration anymore ? @@ +106,4 @@ > return deferred.promise; > } > > +function sendNDEFExpectError(peer) { Nits. remove caller with errorMsg parameter
Attachment #8482653 - Flags: review?(dlee) → review+
(In reply to Dimi Lee[:dimi][:dlee] from comment #13) > Comment on attachment 8482653 [details] [diff] [review] > Part 3: fix tests case. > > Review of attachment 8482653 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: dom/nfc/tests/marionette/test_nfc_error_messages.js > @@ +101,5 @@ > > nfc.onpeerready = null; > > deferred.resolve(); > > }; > > > > + nfc.notifyUserAcceptedP2P(MANIFEST_URL); > > Just curious about removing checkP2PRegistration here because of > |this.currentPeerAppId| is removed > so we don't have to call checkP2PRegistration anymore ? Yeah, remove checkP2PRegistration since now this.currentPeer is set in notifyUserAcceptedP2P. In the original code you will find that the onpeerlost will be notified only if checkP2PRegistration is called because this.currentPeerAppId is set in checkP2PRegistration. In this test file we want onpeeready to be called, checkP2PRegitraion should be tests in the file test_nfc_checkP2PRegistation.js
Note that due to recent policy changes, all patches must have approval for uplift regardless of blocking status. Please request aurora approval on these patches when you get a chance. Sorry for the inconvenience :(
Flags: needinfo?(allstars.chh)
No longer blocks: 1043186
Depends on: 1043186
Flags: needinfo?(allstars.chh)
Comment on attachment 8482061 [details] [diff] [review] Part 1: fix onpeerlost. Approval Request Comment [Feature/regressing bug #]: Bug 1043186 [User impact if declined]: onpeerlost can not be notified, so Gaia apps cannot know the MozNFCPeer is invalid so the object cannot be GCed. [Describe test coverage new/current, TBPL]: Marionette-webapi [Risks and why]: No [String/UUID change made/needed]: No
Attachment #8482061 - Flags: approval-mozilla-aurora?
Comment on attachment 8482102 [details] [diff] [review] Part 2: add removeTarget Approval Request Comment Same with Part 1.
Attachment #8482102 - Flags: approval-mozilla-aurora?
Comment on attachment 8483932 [details] [diff] [review] Part 3: fix tests case. v2 Approval Request Comment Same with Part1.
Attachment #8483932 - Flags: approval-mozilla-aurora?
Attachment #8482061 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Attachment #8482102 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Attachment #8483932 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: