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

[Scopes] expanded properties are not updated while stepping #2509

Merged
merged 11 commits into from Apr 5, 2017

Conversation

arthur801031
Copy link
Contributor

@arthur801031 arthur801031 commented Mar 31, 2017

Associated Issue: #2394

Summary of Changes

  • Assign new values to the cache actor if it goes stale

Test Plan

  1. pause and expand an object
  2. step
  3. check if expanded object has updated

Screenshots/Videos (OPTIONAL)

kapture 2017-03-31 at 14 19 01

@arthur801031
Copy link
Contributor Author

Hi @jasonLaster

The expanded properties would not be updated while stepping is because we're getting the properties from the cache actor instead of the current item's properties. The solution that I got fixes this issue but there is one drawback: we're not actually updating the cache actor; instead, we modify the cache actor locally and return this object to getChildren.

Please let me know if there is a better way to tackle this issue. 😄

}
}
}
return thisActor;
Copy link
Contributor

@bomsy bomsy Mar 31, 2017

Choose a reason for hiding this comment

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

Looking good! If we move this change to the ObjectInspector.js here instead.
Then we can do this.props.setActors(actors); after, which will set the cached actor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion! I thought using this.props.setActors(actors); in render would cause an error, but I was wrong! Thank you! 😊

@bomsy
Copy link
Contributor

bomsy commented Mar 31, 2017

Looking good!

@codecov
Copy link

codecov bot commented Mar 31, 2017

Codecov Report

Merging #2509 into master will increase coverage by 1.12%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2509      +/-   ##
==========================================
+ Coverage   53.24%   54.36%   +1.12%     
==========================================
  Files          51       51              
  Lines        1959     1970      +11     
  Branches      393      396       +3     
==========================================
+ Hits         1043     1071      +28     
+ Misses        916      899      -17
Impacted Files Coverage Δ
src/utils/object-inspector.js 76.47% <100%> (+21.52%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da1b5cf...8557ef9. Read the comment docs.

@@ -100,6 +100,7 @@ class Preview extends Component {
onDoubleClick: () => {},
loadObjectProperties,
getActors: () => ({}),
setActors: () => {},
Copy link
Contributor

Choose a reason for hiding this comment

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

this will return undefined, should be setActors: () => ({}) instead

@@ -162,6 +162,7 @@ class Expressions extends React.Component {
this.editExpression(expression, options),
loadObjectProperties,
getActors: () => ({}),
setActors: () => {},
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@@ -122,6 +122,26 @@ const ObjectInspector = React.createClass({
getChildren(item: ObjectInspectorItem) {
const { getObjectProperties } = this.props;
const { actors } = this;
const key = item.path;

if (item.contents.value && item.contents.value.preview && actors[key]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

tiny note, just for security ... actors && actors[key]

}
}
actors[key] = thisActor;
this.props.setActors(actors);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we can simplify the cache significantly.

The way i see it working is that it would keep a key of IDs that are expanded and that's it. This way, values don't need to be synced...

}
index++;
});
return thisActor;
Copy link
Contributor

Choose a reason for hiding this comment

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

adding actors[key] = thisActor; above this line should update actorCache

Copy link
Contributor

@bomsy bomsy Apr 3, 2017

Choose a reason for hiding this comment

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

Also , the actors[key] only goes stale across the ObjectInspector component loads (i.e during stepping), therefore across internal component renders we should still be fine doing return actors[key]if it exists, due to performance reasons.

@arthur801031
Copy link
Contributor Author

Hi @bomsy and @jasonLaster

I've reverted to previous implementation where the code logic for detecting/updating actors is in shared/ObjectInspector.js. This has 2 benefits:

  1. I think this implementation is more reliable than the one that was in src/utils/object-inspector.js because I had to use multiple if conditions to avoid setting function objects.
  2. We can update actors in shared/ObjectInspector.js, but we can't do that in src/utils/object-inspector.js.

To @bomsy:
I'm not sure if we can know when component loads (i.e during stepping) or internal components being render. What we have right now checks whether or not actors goes stale. If it does, we update actors.

@bomsy
Copy link
Contributor

bomsy commented Apr 4, 2017

ok looking and testing ..

actors[key] = thisActor;
this.props.setActors(actors);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can this move to utils/object-inspector and get some unit tests?

Copy link
Contributor

@jasonLaster jasonLaster left a comment

Choose a reason for hiding this comment

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

couple simplifying comments

@@ -221,4 +222,63 @@ describe("promises", () => {
const node = getPromiseProperties(promise);
expect(node.contents.value.type).to.eql("3");
});

it("update actors when necessary", () => {
const item = {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we remove some of the data from this fixture so that it is much smaller. for instance, do we need the entire value? Can we remove preview's contents?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, please check my new commit :)

@@ -181,6 +181,22 @@ function getChildren(
// node would be a new instance every render.
const key = item.path;
if (actors && actors[key]) {
if (item.contents.value && item.contents.value.preview) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we move this code to an updateActor helper function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem 🙂

@arthur801031 arthur801031 changed the title WIP - [Scopes] expanded properties are not updated while stepping [Scopes] expanded properties are not updated while stepping Apr 5, 2017
@bomsy
Copy link
Contributor

bomsy commented Apr 5, 2017

While testing this yesterday, noticed that if a property does not exist it does not get added.

scope-props-update

I think this will require us going back to get the getProperties again, which invalidates the expanded cache,

I think we can land what we have atm, and improve on this.

@jasonLaster jasonLaster merged commit 1223468 into firefox-devtools:master Apr 5, 2017
DanUgelow pushed a commit to DanUgelow/debugger.html that referenced this pull request May 4, 2017
…devtools#2509)

* Fix expanded properties are not updated while stepping

* Revert yarn.lock

* Move code logic to ObjectInspector

* Made a few corrections

* Retrieve property values

* Remove code from previous commit

* Revert to previous implementation

* Revert yarn.lock

* Move code logic to object-inspector and add a unit test

* Simplify code
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.

None yet

3 participants