Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Live Preview fixes #6889

Merged
merged 15 commits into from
Mar 7, 2014
Merged

Live Preview fixes #6889

merged 15 commits into from
Mar 7, 2014

Conversation

redmunds
Copy link
Contributor

This is for #6122. Also is for #5687. And at least parts of #6830.

I also found a repeatable recipe that was causing connection errors when changing files, so I fixed the case of relaunching browser after "Relaunch Chrome" dialog is shown. See inline comments for more info.

@@ -45,6 +45,9 @@ define(function ConsoleAgent(require, exports, module) {
level = "warn";
}
var text = "ConsoleAgent: " + message.text;
if (message.url) {
text += " (url: " + message.url + ")";
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 404 error message provides a url that is not added to error message. This case I saw ended up not being related to this code, but this is good info to display.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@redmunds
Copy link
Contributor Author

@jasonsanjose Do you want to take a look? I think you were the last one to update this code.

if (_openDeferred.state() === "pending") {
_openDeferred.reject();
}

_doInspectorDisconnect(doCloseWindow).done(cleanup);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a pending _openDeferred should be rejected before disconnecting. This makes the scenario I was using seem to be more reliable when switching files.

@redmunds redmunds assigned ingorichter and unassigned jasonsanjose Feb 19, 2014
@redmunds
Copy link
Contributor Author

@jasonsanjose Re-assigned to @ingorichter

@redmunds
Copy link
Contributor Author

@ingorichter @jasonsanjose Can someone make a first pass through this pull request? We should try to get this in for Release 37, and I have a few questions that still need to be resolved. Thanks.

@@ -589,14 +599,22 @@ define(function LiveDevelopment(require, exports, module) {
_setStatus(status);

result.resolve();
_loadAgentsPromise = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove each addition of _loadAgentsPromise = null; and instead setup the following:

result.always(function () {
  _loadAgentsPromise = null;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better. Thanks.

@jasonsanjose
Copy link
Member

@redmunds initial review complete

reconnect().done(function () {
// Reload HTML page
Inspector.Page.reload();
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, the _onDocumentSaved() event handler could be called again before agents and page are done, but this is probably safe for now since I can't figure out how to hit this code. HTML adn CSS pages have liveEditingEnabled set to true, so the bail out. I tried attaching a JS file, but agents.network.wasURLRequested() returns falsey.

// Agents are already loading, so don't unload
return _loadAgentsPromise;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonsanjose I added better handling of unloadAgents().

@@ -22,7 +22,7 @@
*/

/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, forin: true, maxerr: 50, regexp: true */
/*global define, $, brackets, window */
/*global define, $, brackets, window, open */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New call to open() causes a circular dependency.

@redmunds
Copy link
Contributor Author

@jasonsanjose Ready for another review.

@ingorichter
Copy link
Contributor

Switching the documents will start a new session every time. This seems to be alright now.
F.Y.I. I don't think that this a real use-case, but starting and stopping Live Preview but constantly clicking the icon will result in an error after 4-6 times of doing so. I get an error and the console log shows Inspected frame has gone Object {code: -32000, message: "Inspected frame has gone"}

@njx
Copy link
Contributor

njx commented Feb 26, 2014

@ingorichter That last issue is worth filing - the fact that we get easily confused if you disconnect/reconnect rapidly. Some of the students were running into this at MissionBit.

@@ -1013,10 +1038,8 @@ define(function LiveDevelopment(require, exports, module) {
_close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm questioning now whether or not this is useful. At this point, we've spun up the server and created the main live document, but we just haven't established a connection to Chrome. Either it's not running or we can't connect to the debug port. Does this call to close even make sense?

If not, then I think we can remove it and your change below goes back to _openInterstitialPage without the timeout as you said.

@jasonsanjose
Copy link
Member

Unfortunately, I can still hit the "Unable to load Live Development page" error message following this comment #6889 (comment).

Is it worth it to try changing reconnect to reuse the connection instead of a full teardown and restart?

@jasonsanjose
Copy link
Member

@redmunds I went ahead and changed how we load a new HTML page if live preview is already open. See #7119. I still need to scrub the tagged live preview issues to see which ones this fix addresses.

@jasonsanjose
Copy link
Member

Looks great. Merging.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants