-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
(@annagrin - this tracks details of our discussion yesterday.)
When a user requests an evaluation in frame, today we take a few steps:
- dwds requests frame data from chrome first (like value of locals at that frame scope and parent scopes)
- it then sends a request to the expression evaluation worker to generate javascript for the evaluated expression, including some scope values
- the worker wraps the result in a JS function that provides values for all the variables in scope that may be used in the body of the function
- dwds sends the JavaScript back via the evaluateInFrame API to get a value
- and so on ...
This bug is to track whether in the future we can conditionally skip the extra round trip to request the frame data (step 1).
Step 1 is currently necessary for two reasons:
- We are missing mappings of variables generated by DDC, without it, we can't ensure the expression compiler generates the same names. Using the scope data reduces the impact of this bug and makes the feature usable.
- The v8 engine may optimize away variables that were not captured by a closure. So if evaluated expressions refer to those variables, they are not available when invoking
evaluateInFrame
.
We already have plans to solve the symbol mapping (see #40273) to make expression evaluation more robust. After that, it would be nice to avoid the extra round trip when we can.
We believe we may be able to robustly determine when scope information will be needed. If so, we should be able to change the order of steps (1) and (2), so we only incur the extra round trip when it is necessary.
For example, we think will not need the scope data when:
- evaluation is in a frame that corresponds directly to a regular Dart method (so no closures are involved)
- evaluation is in a closure frame, but the evaluated expression only contains variables that are already captured by the closure