Closed Bug 1152675 Opened 10 years ago Closed 10 years ago

[Bluetooth][APIv2] JS error while goes into Settings::Bluetooth panel

Categories

(Firefox OS Graveyard :: Gaia::Settings, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: iliu, Assigned: iliu)

References

Details

Attachments

(1 file)

JS error while goes into Settings::Bluetooth panel. LOG: W/Settings(19694): [JavaScript Error: "TypeError: this is undefined" {file: "app://settings.gaiamobile.org/js/panels/bluetooth/panel.js" line: 340}]
This is a regression from Bug 1144532. It was missed to bind this while regedit _updateVisibilityTimer() for observable object.
Comment on attachment 8590118 [details] [review] [gaia] ian-liu:bluetooth/bug1152675_btv2_JS_error_while_goes_into_Bluetooth_panel > mozilla-b2g:master Arthur, I feel ashamed that I missed to bind 'this' for _updateVisibilityTimer(). Will need your review here again. Thanks.
Attachment #8590118 - Flags: review?(arthur.chen)
Status: NEW → ASSIGNED
Comment on attachment 8590118 [details] [review] [gaia] ian-liu:bluetooth/bug1152675_btv2_JS_error_while_goes_into_Bluetooth_panel > mozilla-b2g:master oh... too bad. I did not catch this when reviewing. To avoid this kind of error happens again, I would suggest to have a "bound" version of the handlers. ex: this._boundUpdateXXX = this._updateXXX.bind(this); And in `hide`, let's remove the handlers explicitly.
Attachment #8590118 - Flags: review?(arthur.chen)
Comment on attachment 8590118 [details] [review] [gaia] ian-liu:bluetooth/bug1152675_btv2_JS_error_while_goes_into_Bluetooth_panel > mozilla-b2g:master Arthur, Nice catch here for the suggestion. I have updated the patch with the way. That would be more clear than before.
Attachment #8590118 - Flags: review?(arthur.chen)
Comment on attachment 8590118 [details] [review] [gaia] ian-liu:bluetooth/bug1152675_btv2_JS_error_while_goes_into_Bluetooth_panel > mozilla-b2g:master Let's bind "this" to ALL functions before using them as an observer. That avoids potential issues while adding reference to "this" in the future but forget to bind the function.
Attachment #8590118 - Flags: review?(arthur.chen)
Comment on attachment 8590118 [details] [review] [gaia] ian-liu:bluetooth/bug1152675_btv2_JS_error_while_goes_into_Bluetooth_panel > mozilla-b2g:master Arthur, I have updated the patch for all callback functions which observe Bluetooth context. And we don't need to un-observe each callback functions since we have un-observed these properties in 'onBeforeHide' stage. Need your review. Thanks.
Attachment #8590118 - Flags: review?(arthur.chen)
Comment on attachment 8590118 [details] [review] [gaia] ian-liu:bluetooth/bug1152675_btv2_JS_error_while_goes_into_Bluetooth_panel > mozilla-b2g:master Sorry I had to cancel the request again but it should be easy to fix. BluetoothContext is a common module, in the sense that other panels may also observe the property change. Doing `BtContext.unobserve('state');` removes ALL handlers even they are registered by other panels. Although currently we have no such use case but I would suggest to make it robust by removing the handlers explicitly.
Attachment #8590118 - Flags: review?(arthur.chen)
Comment on attachment 8590118 [details] [review] [gaia] ian-liu:bluetooth/bug1152675_btv2_JS_error_while_goes_into_Bluetooth_panel > mozilla-b2g:master Nice catch in this view point. We have to use 'unobserve' carefully. Thanks for the reminder:)
Attachment #8590118 - Flags: review?(arthur.chen)
Comment on attachment 8590118 [details] [review] [gaia] ian-liu:bluetooth/bug1152675_btv2_JS_error_while_goes_into_Bluetooth_panel > mozilla-b2g:master r=me, thanks!
Attachment #8590118 - Flags: review?(arthur.chen) → review+
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: