Closed Bug 1241050 Opened 9 years ago Closed 9 years ago

devtools hot reload addon is weird with gcli commands

Categories

(DevTools Graveyard :: Graphic Commandline and Toolbar, defect)

defect
Not set
normal

Tracking

(firefox47 fixed)

RESOLVED FIXED
Firefox 47
Tracking Status
firefox47 --- fixed

People

(Reporter: pbro, Assigned: ochameau)

References

Details

Attachments

(3 files, 2 obsolete files)

What I did was: - started firefox - made a change to a command (in highlight.js, I just changed the returned output string of the highlight command) - loaded the devtools addon - started the dev toolbar - entered 'highlight div' => I got the expected output (corresponding to the change I had just made in highlight.js) Then: - changed highlight.js again - entered 'highlight div' again in the dev toolbar => I didn't get the new output This seemed sort of expected because I hadn't asked the addon to reload from the sources (but, the first time I did the change either). So I tried: - opened the toolbox - hit ctrl+alt+R to reload from sources - entered 'highlight div' in the dev toolbar again => Same result, I didn't get the new output Then: - restarted firefox - entered 'highlight div' in the dev toolbar again => This time I got the right output for my command. The weird thing with the dev toolbar is that it lives outside of the toolbox, whereas the reload functionality lives inside the toolbox. So as a user it's kind of hard to know what to expect.
Oh wait. The reload shortcut isn't related to the toolbox. You can do it at anytime on any window. We have a special code to reload the toolbox if we happen to hit the shortcut on a window that has a toolbox already opened. I see that the gcli toolbar isn't closed when hitting the reload shortcut. That's a first issue. It should be closed automatically and reopened like the toolbox. Then if you close and reopen it manually, do you see your changes?
Looks like it doesn't reload even when closing the toolbar manually. It is most likely not reloading because of DeveloperToolbar.jsm...
It looks like this is no usage of this JSM in addons: https://mxr.mozilla.org/addons/search?string=DeveloperToolbar.jsm We should be able to convert it to a module.
Component: Developer Tools → Developer Tools: Graphic Commandline and Toolbar
Assignee: nobody → poirot.alex
Just convert it to a module. It doesn't solve the issue, but allows doing so.
Attachment #8717967 - Flags: review?(jwalker)
Based on bug 1247270. Waiting for its review before proceeding. This is the additional trick to ensure we: - destroy any existing toolbar - use the new module instance from browser/ codebase - open a new toolbar if one was already opened We would need to strip all devtools specifics from browser/ and instead inject everything dynamically via Addons APIs (WebExtension/Jetpack/Custom helpers). So that we can easily unregister / re-register stuff within firefox ui on-demand!
Comment on attachment 8717967 [details] [diff] [review] Convert DeveloperToolbar.jsm to commonjs module - v1 Review of attachment 8717967 [details] [diff] [review]: ----------------------------------------------------------------- Yup. Like it, thanks.
Attachment #8717967 - Flags: review?(jwalker) → review+
Now that it is a module, we have access to loader, we can stop using xpcomutils and cleanup its imports.
Attachment #8718113 - Flags: review?(jwalker)
Attachment #8718113 - Flags: review?(jwalker) → review+
Blocks: 1225108
Depends on: 1247270
:jryans just f+ the related code to reload the toolbox and any devtools document living in a tab (about:debugging, jsonview). Looks like we can more ahead and have a similar reload code for gcli. This is the critical patch that will make gcli be reloadable via the addon.
Attachment #8718583 - Flags: review?(jwalker)
Attachment #8717969 - Attachment is obsolete: true
Comment on attachment 8718583 [details] [diff] [review] Ensure reloading the developer toolbar when using the reload addon. Review of attachment 8718583 [details] [diff] [review]: ----------------------------------------------------------------- ::: devtools/bootstrap.js @@ +106,5 @@ > }, false); > } > + > + // Manually reload gcli if it has been used > + // Bug XXX: Inject the developer toolbar dynamically within browser/ Shouldn't we have a number here? @@ +108,5 @@ > + > + // Manually reload gcli if it has been used > + // Bug XXX: Inject the developer toolbar dynamically within browser/ > + // so that we can easily remove/reinject it > + let desc = Object.getOwnPropertyDescriptor(window, "DeveloperToolbar"); const? @@ +111,5 @@ > + // so that we can easily remove/reinject it > + let desc = Object.getOwnPropertyDescriptor(window, "DeveloperToolbar"); > + if (desc && !desc.get) { > + let wasVisible = window.DeveloperToolbar.visible; > + window.DeveloperToolbar.destroy(); It worries me that hide() is async, where destroy() isn't. I think the bug is that if we're doing a destroy() before show() has completed then Bad Things will happen [1]. I'm not sure if we should fix this here. Probably not, unless you think it's likely that this could happen quickly? [1]: https://dxr.mozilla.org/mozilla-central/source/devtools/client/shared/DeveloperToolbar.jsm#497-520
Attachment #8718583 - Flags: review?(jwalker) → review+
(In reply to Joe Walker [:jwalker] (needinfo me or ping on irc) from comment #10) > @@ +111,5 @@ > > + // so that we can easily remove/reinject it > > + let desc = Object.getOwnPropertyDescriptor(window, "DeveloperToolbar"); > > + if (desc && !desc.get) { > > + let wasVisible = window.DeveloperToolbar.visible; > > + window.DeveloperToolbar.destroy(); > > It worries me that hide() is async, where destroy() isn't. I think the bug > is that if we're doing a destroy() before show() has completed then Bad > Things will happen [1]. > > I'm not sure if we should fix this here. Probably not, unless you think it's > likely that this could happen quickly? Note that we call show() on a completely new instance of DeveloperToolbar. So it can save us from some race on the internal state of DeveloperToolbar. Otherwhise, do you think that would help if I wait for hide() completetion before calling destroy() and then show() on the second instance?
Addressed comments and wait for hide() before calling destroy() and show(). I only see exceptions if I start reloading two times in a row, which is yet another issue!
Attachment #8719432 - Flags: review+
Attachment #8718583 - Attachment is obsolete: true
Product: Firefox → DevTools
Product: DevTools → DevTools Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: