-
Notifications
You must be signed in to change notification settings - Fork 5k
'ComWrappers.ReleaseObjects' also passes aggregated objects #114043
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
Comments
This is expected from the runtime perspective. These objects are all associated with the current thread COM apartment and created with the This API is only called when the Jupiter runtime calls This API is about cleaning up thread affinitized objects that require the associated thread for clean-up. |
Oh, interesting. The docs for that say that the method is only called "when a
Out of curiosity, why is this called in the same context in this case, yet all other tracker objects we create are just finalized on whatever thread the finalizer happens to run on? Why aren't those also finalized on the same original context? |
Great question. I defer to the Jupiter team on this. We simply provide the callout.
That I do not know. Again, this is an API that is exposed for the Jupiter runtime. I will circle back today and confirm the state in .NET Framework. |
Looking at the .NET Framework version, there is a slight nuance that isn't captured in the documentation. RCWs are cleaned up in a 2 pass operation. In the first pass, all non-aggregated RCWs are released. In the second pass, all aggregated RCWs are released. This is something that would need to be implemented in the CsWinRT
Based on the various snippets of comments, both in the Jupiter runtime and in .NET Framework, it looks like this is an optimization to avoid releasing too much on the finalizer. |
Talked with Aaron offline. Closing this, as the behavior is expected. We'll look into changing impl on the CsWinRT side. |
Related to microsoft/CsWinRT#1955
Description
It seems that
ComWrappers.ReleaseObjects
is called with some objects also potentially being aggregated objects (eg. a type deriving fromWindows.UI.Xaml.Controls.Page
). This currently causes CsWinRT to throw an exception, as we can't unwrap the object. That is by design, as our understanding was thatReleaseObjects
would only be called with unwrappable RCWs from our ownComWrappers
.I'm not sure whether this is a bug or expected. It feels like at the very least we could improve the docs for
ReleaseObjects
? Currently the method is pretty cryptic, as it just takes someIEnumerable
and gives you no info whatsoever on when would the method actually be called, or what objects an implementing type should expected to be passed to it, and/or what should the behavior be for objects you can't manually release.Reproduction Steps
Expected behavior
Not clear.
Actual behavior
ComWrappers.ReleaseObject
is also receiving some aggregated objects.The text was updated successfully, but these errors were encountered: