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)
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}]
Assignee | ||
Comment 1•10 years ago
|
||
This is a regression from Bug 1144532. It was missed to bind this while regedit _updateVisibilityTimer() for observable object.
Comment 2•10 years ago
|
||
Assignee | ||
Comment 3•10 years ago
|
||
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)
Assignee | ||
Updated•10 years ago
|
Status: NEW → ASSIGNED
Comment 4•10 years ago
|
||
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)
Assignee | ||
Comment 5•10 years ago
|
||
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 6•10 years ago
|
||
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)
Assignee | ||
Comment 7•10 years ago
|
||
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 8•10 years ago
|
||
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)
Assignee | ||
Comment 9•10 years ago
|
||
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 10•10 years ago
|
||
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+
Updated•10 years ago
|
Keywords: checkin-needed
Updated•10 years ago
|
Keywords: checkin-needed
Comment 11•10 years ago
|
||
Pull request has landed in master: https://github.com/mozilla-b2g/gaia/commit/cd43da30b1c3a0ee00e9d6f6f7d744e3b852fd62
Updated•10 years ago
|
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.
Description
•