Closed
Bug 1417039
Opened 8 years ago
Closed 8 years ago
Do not defer loading JSON Viewer
Categories
(DevTools :: JSON Viewer, enhancement, P3)
DevTools
JSON Viewer
Tracking
(firefox59 fixed)
RESOLVED
FIXED
Firefox 59
| Tracking | Status | |
|---|---|---|
| firefox59 | --- | fixed |
People
(Reporter: Oriol, Assigned: Oriol)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
Attachments
(1 file)
Currently the JSON Viewer is not loaded until all the JSON has been received.
It would be better to start loading it as soon as possible.
Since we don't have a partial JSON parser, the tree can't be displayed until all data has been received. Then I would select the Raw Data tab by default, so that the user can see how the JSON is being downloaded, and at the end automatically switch to the JSON tab.
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 2•8 years ago
|
||
This ended up being a bigger patch than I expected, but mostly it's due to tests. In order to be able to test this, I added a JSONView.readyState (inspired by document.readyState) to know the load state of the app. I modified the addJsonViewTab test function to use these states instead of a timeout, and adapted the only test that used that timeout. While I was at it, I sorted some browser.ini entries which were at the wrong position.
Other than this, the patch basically passes a DOM text node to react instead of a string. This way the node can be updated and the change happens immediately. Passing a string or an array of string chunks to react had awful, awful, awful performance for big JSON data.
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 4•8 years ago
|
||
Rebased the patch.
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 7•8 years ago
|
||
Found a less hacky way to wait until the tab is ready but not loaded. And renamed the "initial" JSONView.readyState to "uninitialized" because that's the non-standard document.readyState value that Firefox uses.
Updated•8 years ago
|
Priority: -- → P3
Comment 8•8 years ago
|
||
| mozreview-review | ||
Comment on attachment 8928664 [details]
Bug 1417039 - Do not defer loading JSON Viewer.
https://reviewboard.mozilla.org/r/199902/#review208470
Thanks for working on this.
Just a few nit inline comments
Also, do you have a test page I could try to test the new behavior?
Honza
::: devtools/client/jsonview/test/browser_jsonview_chunked_json.js:19
(Diff revision 4)
> + appReadyState: "interactive",
> + docReadyState: "loading",
> + });
> +
> + is(await getElementCount(".rawdata.is-active"), 1,
> + "The Raw Data tab is selected.");
nit: indentation should be 2 spaces
::: devtools/client/jsonview/test/browser_jsonview_chunked_json.js:25
(Diff revision 4)
> +
> + // Write some text and check that it is displayed.
> + await write("[");
> + await checkText();
> +
> + // Reapeat just in case.
typo: Reapeat -> Repeat
::: devtools/client/jsonview/test/browser_jsonview_chunked_json.js:30
(Diff revision 4)
> + // Reapeat just in case.
> + await write("1,");
> + await checkText();
> +
> + is(await getElementCount("button.prettyprint"), 0,
> + "There is no pretty print button during load");
nit: indentation should be 2 spaces
::: devtools/client/jsonview/test/browser_jsonview_chunked_json.js:37
(Diff revision 4)
> + await selectJsonViewContentTab("json");
> + is(await getElementText(".jsonPanelBox > .panelContent"), "", "There is no JSON tree");
> +
> + await selectJsonViewContentTab("headers");
> + ok(await getElementText(".headersPanelBox .netInfoHeadersTable"),
> + "The headers table has been filled.");
nit: indentation should be 2 spaces
::: devtools/client/jsonview/test/browser_jsonview_chunked_json.js:54
(Diff revision 4)
> + await server("close");
> +
> + is(await getElementCount(".json.is-active"), 1, "The JSON tab is selected.");
> +
> + is(await getElementCount(".jsonPanelBox .treeTable .treeRow"), 2,
> + "There is a tree with 2 rows.");
nit: indentation should be 2 spaces
| Assignee | ||
Comment 9•8 years ago
|
||
(In reply to Jan Honza Odvarko [:Honza] from comment #8)
> Also, do you have a test page I could try to test the new behavior?
If you have a server with php, this will do the trick:
<?php
header('Content-type: application/json');
set_time_limit(0);
$i = 0;
echo "[\n";
while($i < 10) {
++$i;
echo " ", $i, ",\n";
ob_end_flush();
flush();
ob_start();
sleep(1);
}
echo " 0\n]";
?>
Comment 10•8 years ago
|
||
| mozreview-review | ||
Comment on attachment 8928664 [details]
Bug 1417039 - Do not defer loading JSON Viewer.
https://reviewboard.mozilla.org/r/199902/#review208966
(In reply to Oriol Brufau [:Oriol] from comment #9)
> (In reply to Jan Honza Odvarko [:Honza] from comment #8)
> > Also, do you have a test page I could try to test the new behavior?
>
> If you have a server with php, this will do the trick:
>
> <?php
> header('Content-type: application/json');
> set_time_limit(0);
> $i = 0;
> echo "[\n";
> while($i < 10) {
> ++$i;
> echo " ", $i, ",\n";
> ob_end_flush();
> flush();
> ob_start();
> sleep(1);
> }
> echo " 0\n]";
> ?>
Thanks!
Just for the record, I had to also switch off compression to make it work (in my .htaccess file)
<FilesMatch "\.(php|html?)$">
php_flag zlib.output_compression off
</FilesMatch>
Works great for me!
R+
Honza
Attachment #8928664 -
Flags: review?(odvarko) → review+
| Comment hidden (mozreview-request) |
Comment 13•8 years ago
|
||
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/65334d5e3012
Do not defer loading JSON Viewer. r=Honza
Keywords: checkin-needed
Comment 14•8 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox59:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 59
Comment 15•8 years ago
|
||
Backed out changeset 65334d5e3012 (bug 1417039) for frequently failing in devtools/client/jsonview/test/browser_jsonview_chunked_json.js (Bug 1421520) r=backout a=backout
https://hg.mozilla.org/mozilla-central/rev/ba283baf4e98aa3a5f45a17981077b98697aa73a
More information is available in Bug 1421520
Flags: needinfo?(oriol-bugzilla)
Updated•8 years ago
|
Status: RESOLVED → REOPENED
status-firefox59:
fixed → ---
Resolution: FIXED → ---
Target Milestone: Firefox 59 → ---
| Assignee | ||
Comment 18•8 years ago
|
||
OK, so I guess that after closing the connection I should wait an AppReadyStateChange event to make sure the app is loaded.
Flags: needinfo?(oriol-bugzilla)
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 20•8 years ago
|
||
Comment on attachment 8928664 [details]
Bug 1417039 - Do not defer loading JSON Viewer.
I think now it should work.
Attachment #8928664 -
Flags: review+ → review?(odvarko)
Comment 21•8 years ago
|
||
| mozreview-review | ||
Comment on attachment 8928664 [details]
Bug 1417039 - Do not defer loading JSON Viewer.
https://reviewboard.mozilla.org/r/199902/#review210102
Looks reasonable
R+
Honza
Attachment #8928664 -
Flags: review?(odvarko) → review+
| Assignee | ||
Comment 22•8 years ago
|
||
Probably the patch caused bug 1421882 and bug 1421956.
INFO - Adding a new JSON tab with URL: 'data:application/json,{"x":{"type":"string"}}'
INFO - Adding a new tab with URL: data:application/json,{"x":{"type":"string"}}
INFO - Expecting message Test:JsonView:DocReadyStateChange from content
INFO - Tab added and finished loading
INFO - Buffered messages finished
INFO - TEST-UNEXPECTED-FAIL | devtools/client/jsonview/test/browser_jsonview_object-type.js | Test timed out -
A time out while waiting for Test:JsonView:DocReadyStateChange. Maybe the ready state changes between reading it and adding the listener? Normally this shouldn't happen, but it seems there is some dark magic that allows to access the CPOW, and if it's in another process I guess it's possible.
let {document} = content.window;
while (docReadyStates.indexOf(document.readyState) < docReadyIndex) {
await waitForContentMessage("Test:JsonView:DocReadyStateChange");
}
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 24•8 years ago
|
||
This should fix bug 1421882. Will think if I can do something for bug 1421956.
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 27•8 years ago
|
||
I think using ContentTask.spawn to run the code in the content process might solve bug 1421956.
| Assignee | ||
Comment 28•8 years ago
|
||
Comment on attachment 8928664 [details]
Bug 1417039 - Do not defer loading JSON Viewer.
I did some try pushes and all seem OK
https://treeherder.mozilla.org/#/jobs?repo=try&revision=cd0dcb9b86e6
https://treeherder.mozilla.org/#/jobs?repo=try&revision=d522e34d5257
https://treeherder.mozilla.org/#/jobs?repo=try&revision=fe5ef3f024d1
https://treeherder.mozilla.org/#/jobs?repo=try&revision=05b72eb65795
Attachment #8928664 -
Flags: review?(odvarko)
Comment 29•8 years ago
|
||
| mozreview-review | ||
Comment on attachment 8928664 [details]
Bug 1417039 - Do not defer loading JSON Viewer.
https://reviewboard.mozilla.org/r/199902/#review210544
Thanks for the update Oriol, looks reasonable.
Honza
Attachment #8928664 -
Flags: review?(odvarko) → review+
| Assignee | ||
Updated•8 years ago
|
Keywords: checkin-needed
Comment 30•8 years ago
|
||
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/8b81d2b60acf
Do not defer loading JSON Viewer. r=Honza
Keywords: checkin-needed
Comment 31•8 years ago
|
||
| bugherder | ||
Status: REOPENED → RESOLVED
Closed: 8 years ago → 8 years ago
status-firefox59:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 59
Updated•8 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•