Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

[WIP] Use devtools-reps-0.19.0#4915

Merged
jasonLaster merged 7 commits into
firefox-devtools:masterfrom
nchevobbe:reps
Jan 19, 2018
Merged

[WIP] Use devtools-reps-0.19.0#4915
jasonLaster merged 7 commits into
firefox-devtools:masterfrom
nchevobbe:reps

Conversation

@nchevobbe

@nchevobbe nchevobbe commented Dec 13, 2017

Copy link
Copy Markdown
Member

Updating to the latest devtools-reps means that we need to change how we instantiate ObjectInspector.

This is a wip because :

  • devtools-reps-0.17.0 is not published yet
  • I didn't checked the tests
  • The Popup does not seem to work.

Yet, watch expressions and scopes are fine.

@nchevobbe nchevobbe force-pushed the reps branch 2 times, most recently from 0ecce42 to 6cc0e63 Compare December 14, 2017 19:39
@jasonLaster

Copy link
Copy Markdown
Contributor

This is looking good @nchevobbe. Nice work w/ createObjectClient

@nchevobbe

Copy link
Copy Markdown
Member Author

So the only thing with this patch is that the preview show you the root (which is then autoexpanded)

before:
screen shot 2017-12-15 at 12 59 43

after:
screen shot 2017-12-15 at 13 03 08

@nchevobbe

Copy link
Copy Markdown
Member Author

Also: photon colors !

@nchevobbe

Copy link
Copy Markdown
Member Author

Here's the "flashing" issue I talked you about @jasonLaster :

dec-17-2017 12-38-01

Basically, it's the time we have to wait for properties to be loaded. This is a big case here since we target document, which has a lot of things.
We could prevent to render until we have everything loaded to make it better, but the latency to actually show something in the preview might be an issue ? (probably not more than what we were doing previously).

@nchevobbe

Copy link
Copy Markdown
Member Author

Okay so yeah, just tested the same case in Nightly, and we do have this latency on document, the only thing being we don't show anything until we have all properties loaded.

@jasonLaster

Copy link
Copy Markdown
Contributor

@nchevobbe i don't mind delaying showing the preview. It should be snappy on most objects.

I suppose we could also try some animations too. Perhaps there's something fun we could do with animating the yellow highlight? dunno

@nchevobbe

Copy link
Copy Markdown
Member Author

okay, nice
So do we have clear next steps to make this PR landed ?

@jasonLaster

Copy link
Copy Markdown
Contributor

Lets treat the preview loading behavior as a next step. And just focus on getting the tests passing now

@nchevobbe

Copy link
Copy Markdown
Member Author

Sure, CI is failing because of Flow. Let me fix this now

@nchevobbe

Copy link
Copy Markdown
Member Author

Erf, at this point, we would break preview for React and Immutable https://github.com/devtools-html/debugger.html/pull/4915/files#diff-2e80e25aeaf08281d8427771196d61e1R101 . 😕

@MikeRatcliffe do you think you could have a look and see how we could do thing in the ObjectInspector to autoLoad properties and get them back in some way, so we don't have to change much code for the Preview here ?

@jasonLaster

Copy link
Copy Markdown
Contributor

@nchevobbe happy to look in a bit

@jasonLaster

Copy link
Copy Markdown
Contributor

Did a quick look

  • Immutable did not seem to regress
  • the preview font is bigger
  • the source tree seems clipped
  • previewing a react component breaks STR: go to this site and add a breakpoint in App.js

screen shot 2017-12-19 at 9 17 12 am

screen shot 2017-12-19 at 9 13 51 am

screen shot 2017-12-19 at 9 13 09 am

@MikeRatcliffe

MikeRatcliffe commented Dec 19, 2017

Copy link
Copy Markdown

When we are trying to preview this inside a React component the following error is thrown:

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the ObjectInspector component. 13 warning.js:33
printWarning warning.js:33
warning warning.js:57
getInternalInstanceReadyForUpdate ReactUpdateQueue.js:46
enqueueSetState ReactUpdateQueue.js:207
ReactComponent.prototype.setState ReactBaseClasses.js:62
setExpanded index.js:310:8

Not sure why it is unmounted at this point.

@nchevobbe

Copy link
Copy Markdown
Member Author

Okay, I guess we need some ObjectInspector changes here

@nchevobbe

Copy link
Copy Markdown
Member Author

source tree is now fixed.
We use devtools-reps-0.17.0

I think the error about setState is when we hover quickly a variable and then mouseleave.
This causes the ObjectInspector to be mounted, rendered, making him fetching the first level properties, and thus trying to do a setState. But at this point, the OI is unmounted because we not longer hover the variable in the debugger.
I am not sure how this can be fixed, but I think I want to keep the same behavior as before , which means we need to modify reps.

@nchevobbe nchevobbe force-pushed the reps branch 2 times, most recently from 160e7ef to e8c4c79 Compare January 8, 2018 10:04
@nchevobbe nchevobbe changed the title [WIP] Use devtools-reps-0.16.0 [WIP] Use devtools-reps-0.18.0 Jan 9, 2018
@nchevobbe nchevobbe force-pushed the reps branch 3 times, most recently from 48e7ee4 to 53d8d7a Compare January 9, 2018 16:46
@nchevobbe

Copy link
Copy Markdown
Member Author

@jasonLaster The popup is working just like before now, but i did not tested the React and Immutable cases.
I didn't fixed the mochitests and did not refactor the loadObjectProperties action much because I wanted to check if you are okay with this approach.

This is based on firefox-devtools/devtools-core#884, which will probably be in a 0.19.0 reps package.

There is also a minor styling issue (see firefox-devtools/devtools-core#886)

@codehag codehag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks quite good! a couple of comments regarding type annotation

Comment thread src/client/firefox.js Outdated

let DebuggerClient;

function createObjectClient(grip: Object) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could we use the Grip type here from flow-typed/debugger-html? https://github.com/devtools-html/debugger.html/blob/master/flow-typed/debugger-html.js#L235

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sure

Comment thread src/components/Editor/Preview/Popup.js Outdated
} = this.props;
const root = createNode(null, expression, expression, { value });

if (!nodeIsPrimitive(root) && value.actor && !loadedObjects[value.actor]) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

before, the value was potentially null -- is that no longer the case? maybe we can type this?

expression,
loadObjectProperties,
loadedObjects
} = this.props;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The function has changed to componentWillMount, so this.props will be representing the previous props. do we want to use this.props or nextProps?

Comment thread src/components/Editor/Preview/Popup.js Outdated

getChildren(root: Object, getObjectProperties: Function) {
const actors = {};
getChildren(root: Object) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it is, thanks for pointing to the type

Comment thread src/components/Editor/Preview/Popup.js Outdated
@@ -103,16 +123,18 @@ export class Popup extends Component<Props> {
}

renderObjectPreview(expression: string, root: Object, extra: Object) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also maybe here we can use the node type for root: https://github.com/devtools-html/debugger.html/blob/master/src/utils/sources-tree/types.js#L14

it will need to be moved to a more general type

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes

// TODO: See https://github.com/devtools-html/debugger.html/issues/3555.
getObjectEntries={actor => {}}
loadObjectEntries={grip => {}}
createObjectClient={grip => createObjectClient(grip)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 nice!

// TODO: See https://github.com/devtools-html/debugger.html/issues/3555.
getObjectEntries={actor => {}}
loadObjectEntries={grip => {}}
createObjectClient={grip => createObjectClient(grip)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎉

>
<ObjectInspector
autoExpandDepth={0}
createObjectClient={[Function]}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

its just a code deletion party! hurray!

@nchevobbe

Copy link
Copy Markdown
Member Author

I think everything is working fine now, except:

  • it requires devtools-reps-0.19.0 (on its way)
  • it certainly breaks ChromeScope
  • and mochitest who rely on LOAD_OBJECT_PROPERTIES (the action was changed to only set popup object properties)

@jasonLaster

Copy link
Copy Markdown
Contributor

i can git rm ChromeScope it was an experiment for CDP but hasnt been touched in awhile

@nchevobbe nchevobbe changed the title [WIP] Use devtools-reps-0.18.0 [WIP] Use devtools-reps-0.19.0 Jan 16, 2018
@nchevobbe

Copy link
Copy Markdown
Member Author

Okay, so everything is working now, devtools-reps-0.19.0 has been published, we're in a good place.
Except for those tests.
A bunch of them are using something like await waitForDispatch(dbg, "LOAD_OBJECT_PROPERTIES"); which awaits forever since we don't have this action anymore (or even something that could replace it).

I'm not sure how to tackle this, should I edit all the tests so they don't rely on this action, but more on the UI ? Something like "wait until this .tree element has more than 1 node" ?

That's how it's done in the console, but here it will differ from what the test are doing 🤔

@jasonLaster do you have an idea how I can tackle this without rewriting all the tests ?

@jasonLaster

jasonLaster commented Jan 16, 2018

Copy link
Copy Markdown
Contributor

yep - lets wait for the dom to have rendered loaded scope variables...

@nchevobbe

Copy link
Copy Markdown
Member Author

okay, i'm down to 3 mochitests failing.
At least 2 of them are failing because the PR breaks the Scopes "remapping", I need to check what's going on

@nchevobbe

Copy link
Copy Markdown
Member Author

okay I get it.
The ObjectInspector keeps a Map of cached nodes, which is never cleaned up.
When remapping the scope, we use the same OI instance, and so auto-expanded node, which were cached, are not updated.

This means one more change in Reps to fix this :/

@nchevobbe

Copy link
Copy Markdown
Member Author

@jasonLaster everything is working now (with firefox-devtools/devtools-core#905), so this PR is good for review.
It seems that there are conflicts I'll resolve tomorrow

Since we don't have the LOAD_OBJECT_PROPERTIES anymore,
we need to find other ways to wait for the properties
to be loaded in tests.
@nchevobbe

Copy link
Copy Markdown
Member Author

not sure what's going in with retext-spell, but aside from that everything is good (with the pending reps PR).
@jasonLaster this is ready for review

@wldcordeiro

Copy link
Copy Markdown
Contributor

@nchevobbe you need to add setPopupObjectProperties to /assets/dictionary.txt I believe.

@wldcordeiro wldcordeiro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is packed with so much good stuff! I'm excited to see this land.

Comment thread src/client/firefox.js
let DebuggerClient;

function createObjectClient(grip: Grip) {
return DebuggerClient.createObjectClient(grip);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mochitest is failing here because the assignment in the onConnect below hadn't happened yet. Should you put a guard in to check if the client isn't undefined?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it was failing because of https://bugzilla.mozilla.org/show_bug.cgi?id=1430799, which now landed in mozilla-central.
Locally, all the mochitest pass with --verify :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah good to know. I saw the failure complaining about undefined and figured it was some async funkiness. Guess we just need to update the CI image?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i'm not familiar with this, but if this mean the CI image needs to be updated to pick up mozilla-central changes, then yes :)

@jasonLaster jasonLaster Jan 19, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@nchevobbe you can update the .travis.yml w/ the new mc sha

@nchevobbe

Copy link
Copy Markdown
Member Author

@nchevobbe you need to add setPopupObjectProperties to /assets/dictionary.txt I believe.

Yes ! Thanks, I fixed it in the PR (and took this opportunity to sort the dictionary as well).

node.click();
return waitUntil(
() => objectInspector.querySelectorAll(".node").length !== properties
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't we wait till it is the same?

can we move this to a helper?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

nope, since we expand a node, the result should be that the objectInspector has a different number of nodes

return new Promise(r => setTimeout(r, 3000000));
}

function getScopeNodeLabel(dbg, index) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lol

Comment thread src/test/mochitest/head.js Outdated
);
async function waitForLoadedScopes(dbg) {
await waitUntil(() => findElement(dbg, "scopes"));
const scopes = findElement(dbg, "scopes");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this can be const scopes = await waitUntil(() => findElement(dbg, "scopes"));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

mh, I'll try, but I looked up the waitUntil function, and it was resolving with true, not the result of the condition.
Though, I did not try what you suggest here, so I will

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this makes test fail because scopes.querySelector is not a function.

This is explained by https://searchfox.org/mozilla-central/rev/2031c0f517185b2bd0e8f6f92f9491b3410c1f7f/devtools/client/framework/test/shared-head.js#453-462 , where waitUntil resolves with true.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh, i think we have waitForElement :)

return waitUntil(
() => objectInspector.querySelectorAll(".node").length !== properties
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps we can have helpers like this in mochitest/head.js?

async function toggleExpression() {
  const objectInspector = findElement(dbg, "expressionNode", index).closest(".object-inspector");
  await toggleObjectInspectorNode(dbg, objectInspector);
}

async function toggleObjectInspectorNode(dbg, objectInspector) {
   const getNumProperties = () => objectInspector.querySelectorAll(".node").length;
   const numProperties = getNumProperties();
   node.click();
   return waitUntil(() => numProperties !== getNumProperties());
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah, sounds like a good idea

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

node.click();
return waitUntil(
() => objectInspector.querySelectorAll(".node").length !== properties
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

function toggleNode(dbg, index) {
  const objectInspector = findElement(dbg, "scopeNode", index).closest(".object-inspector");
  return toggleObjectInspectorNode(dbg, objectInspector);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

const properties = await onLoadItemProperties;
setPopupObjectProperties(value, properties);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this looks like it could be moved to a util in the debugger or reps project.

I'm thinking this because it pulls in a bunch of dependencies and is pretty complicated...

could we move some of this logic to the actions/pause/setupPopup...

@jasonLaster jasonLaster merged commit 6d4220e into firefox-devtools:master Jan 19, 2018
jasonLaster pushed a commit that referenced this pull request Jan 24, 2018
@nchevobbe nchevobbe deleted the reps branch October 25, 2018 15:20
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.

5 participants