Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestDataAsync causes two TransferData calls #461

Open
Giorgi opened this issue Feb 15, 2025 · 2 comments
Open

RequestDataAsync causes two TransferData calls #461

Giorgi opened this issue Feb 15, 2025 · 2 comments
Assignees
Milestone

Comments

@Giorgi
Copy link

Giorgi commented Feb 15, 2025

When debugging my extension I have noticed that sometimes a single call to RequestDataAsync results in two calls of TransferData. Is there anything I can do to avoid the second call?

@mpeyrotc mpeyrotc self-assigned this Feb 27, 2025
@mpeyrotc mpeyrotc added this to the Triage milestone Feb 27, 2025
@mpeyrotc
Copy link
Member

Hello @Giorgi could I bother you with the call stacks for the two calls into TransferData so that I can investigate further? Thanks!

@Giorgi
Copy link
Author

Giorgi commented Feb 27, 2025

@mpeyrotc I'm unsure how to attach a debugger to the class that inherits from VisualizerObjectSource so I added a few Debug.WriteLine calls.

Here is how TransferData looks: https://github.com/Giorgi/EFCore.Visualizer/blob/c2ee2156f438b0edd29b42558dd5cb327a2faa73/src/IQueryableObjectSource/EFCoreQueryableObjectSource.cs#L15

var operationType = ReadOperationType(incomingData);

Debug.WriteLine($"TransferData called for {operationType}. Stacktrace: ");
Debug.WriteLine(Environment.StackTrace);

switch (operationType)
{
    case OperationType.GetQuery:
        GetQuery(queryable, outgoingData);
        break;
    case OperationType.GetQueryPlan:
        GetQueryPlan(queryable, outgoingData);
        break;
    case OperationType.Unknown:
    default:
        outgoingData.WriteError("Unknown operation type");
        break;
}

The visualizer part makes two calls to the RequestDataAsync but I get three hits at TransferData. GetQueryAsync and GetQueryPlanAsync call RequestDataAsync internally. I have noticed that only the call to GetQueryPlanAsync causes two calls of TransferData

(var _, var _, filePath) = await GetQueryAsync();

var (isError, error, planFilePath) = await GetQueryPlanAsync();

TransferData called for GetQuery. Stacktrace:
at System.Environment.get_StackTrace()
at IQueryableObjectSource.EFCoreQueryableObjectSource.TransferData(Object target, Stream incomingData, Stream outgoingData)
at Microsoft.VisualStudio.DebuggerVisualizers.DebuggeeSide.Impl.ClrCustomVisualizerDebuggeeHost.TransferData(Object visualizedObject, Byte[] uiSideData)
at MySqlEFCoreDemo.Program.Main(String[] args) in S:\src\ConsoleApp2\MySqlEFCoreDemo\Program.cs:line 14

TransferData called for GetQueryPlan. Stacktrace:
at System.Environment.get_StackTrace()
at IQueryableObjectSource.EFCoreQueryableObjectSource.TransferData(Object target, Stream incomingData, Stream outgoingData)
at Microsoft.VisualStudio.DebuggerVisualizers.DebuggeeSide.Impl.ClrCustomVisualizerDebuggeeHost.TransferData(Object visualizedObject, Byte[] uiSideData)
at MySqlEFCoreDemo.Program.Main(String[] args) in S:\src\ConsoleApp2\MySqlEFCoreDemo\Program.cs:line 14

TransferData called for GetQueryPlan. Stacktrace:
at System.Environment.get_StackTrace()
at IQueryableObjectSource.EFCoreQueryableObjectSource.TransferData(Object target, Stream incomingData, Stream outgoingData)
at Microsoft.VisualStudio.DebuggerVisualizers.DebuggeeSide.Impl.ClrCustomVisualizerDebuggeeHost.TransferData(Object visualizedObject, Byte[] uiSideData)
at MySqlEFCoreDemo.Program.Main(String[] args) in S:\src\ConsoleApp2\MySqlEFCoreDemo\Program.cs:line 14

I have also noticed that this happens only during the first hit of the breakpoint. When another breakpoint is hit, and I inspect some variable with my visualizer, I don't get duplicated hits.

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

No branches or pull requests

2 participants