-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Made other vulkan objects cleanup properly. #42113
Conversation
80422ed to
75db280
Compare
|
But I'm wondering whether that is necessary given that If |
75db280 to
2e89d03
Compare
I was just trying to preserve the old logic but I think you are right. I'll get rid of that smart pointer that resets the instance variable before review. |
d9a07d6 to
44b35d1
Compare
|
I'm still running into trouble getting the tests to run on CI. They run fine locally but crash with no warning on CI. I'm trying turning on debug build runs of the tests too to see if they give more information. I'm noticing that the bots are x86, so maybe that is the x-factor that makes the tests crash. |
dce5026 to
f7859be
Compare
| vk::UniqueDevice device = std::move(device_result.value); | ||
|
|
||
| // Make sure this ivar is set before handing out DeviceHolder references. | ||
| device_ = std::move(device_result.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set every ContextVK member as it is created in Setup instead of setting all of the members at the end of the method.
If Setup fails, then this will ensure that the ContextVK destructor deletes the objects in the proper order. In particular, objects tied to the device should be deleted before the device, and the Vulkan instance should be deleted last.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor code that doesn't have to do with the change? I'd rather do that as a followup PR if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's related to this change - in the current version of this PR if Setup exits early it will set device_ in ContextVK but not any other members.
In particular, instance_ is not set by Setup until the end. So if a failure happens during Setup, the instance local to Setup will be destroyed but device_ will not be destroyed until the ContextVK is destructed.
IIUC it's unsafe to call a Vulkan API like vkDestroyDevice if the instance used to create the device has already been destroyed. So I think it would be safest to set all the ContextVK members as they are created and then rely on the ContextVK destructor to delete the context's Vulkan objects in the correct order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good observation. That requires that the ivars of the context are in the correct order in the header which at least for the device and instance is the case. It also means the that the order in which the ivars are set in Setup is meaningful. If we space it out across this whole method, it would be easy to get wrong. I'm back to liking the resetter on the stack that I had at first. It makes it easy to verify the order and is the least invasive to what we already have.
I'm just seeing that you are out of office. Let's go over our options when you get back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it, if the order of the ivars is wrong, then the order on the stack would be wrong too. So that doesn't solve the problem. I don't think there is a way you can guarantee this code is safe to all failures. Your proposal is better than what it is now though. I'll make the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting to implement it, I don't like it since on line X we initialize an instance variable and line X+100 we use it. It isn't clear that that instance variable has been initialized at X+100. By using values on the stack and initializing them when we create them we can't get them out of order. Let's chat when you get back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no way to make this completely foolproof.
But I think the requirement that a constructor must initialize members before it uses them later is well understood. It will be more familiar to readers of the code than the scoped_reset class and the requirement to call release() on the scoped_reset at the right time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got rid of the special smart pointer and moved resetting the ivar to a std::unique_ptr. I think you'll find that preferable.
But I think the requirement that a constructor must initialize members before it uses them later is well understood.
It's not that it's not understood, it's impossible to verify when looking at the code without scrolling around because the method is so large.
It will be more familiar to readers of the code than the scoped_reset class and the requirement to call release() on the scoped_reset at the right time.
The nice thing is that they don't have the release, the tests will fail. The order of the release isn't super important as long as it remains in the same spot since the chances of errors in that block of code where all the ivars is getting set is practically zero (possibly zero, i didn't look up std::optional::value or std::string::string's signatures).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Jason. I have a followup draft PR that will expand the functionality of mock vulkan so that we can assert the behavior when there is an error at setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I give up, I can't make Setup fail because in practice we abort if there is any vulkan error. 🤷
|
|
||
| auto sampler_library = | ||
| std::shared_ptr<SamplerLibraryVK>(new SamplerLibraryVK(device.get())); | ||
| std::shared_ptr<SamplerLibraryVK>(new SamplerLibraryVK(device_.get())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't look into it but, I suspect this guy and the FenceWaiterVK may need device holders too.
| device_ = std::move(device_result.value); | ||
| // This makes sure that the device is deleted at the proper time if there is | ||
| // an error. | ||
| std::unique_ptr<vk::UniqueDevice, std::function<void(vk::UniqueDevice*)>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use fml::ScopedCleanupClosure here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…127292) flutter/engine@aac0919...f0f3fe7 2023-05-21 [email protected] Roll Skia from 7c7dff949a27 to 5b2005e47bf3 (1 revision) (flutter/engine#42199) 2023-05-21 [email protected] Roll Fuchsia Linux SDK from gQ989rlKAuTJHQR-C... to 88pzkUAkSKsJrNG38... (flutter/engine#42198) 2023-05-21 [email protected] Roll Fuchsia Mac SDK from 868_67npyO8nD_JCx... to JU-dKW3CQIUzhbqWE... (flutter/engine#42197) 2023-05-21 [email protected] Roll Skia from a60bfcb01af9 to 7c7dff949a27 (1 revision) (flutter/engine#42195) 2023-05-20 [email protected] Roll Fuchsia Linux SDK from c_fRDyBVZX-MwW5fS... to gQ989rlKAuTJHQR-C... (flutter/engine#42194) 2023-05-20 [email protected] Roll Skia from f3e9cb7d37fd to a60bfcb01af9 (1 revision) (flutter/engine#42193) 2023-05-20 [email protected] Roll Fuchsia Mac SDK from sfLkc5VBFU6UkljF6... to 868_67npyO8nD_JCx... (flutter/engine#42191) 2023-05-20 [email protected] Move SkSurface::MakeNull to SkSurfaces::Null (flutter/engine#42158) 2023-05-20 [email protected] Roll Fuchsia Linux SDK from TWjmvLCOnYAUgAzvT... to c_fRDyBVZX-MwW5fS... (flutter/engine#42189) 2023-05-20 [email protected] Roll Skia from b4a4782cf89d to f3e9cb7d37fd (1 revision) (flutter/engine#42188) 2023-05-20 [email protected] Roll Fuchsia Mac SDK from pwdDQgM88sqLmZczj... to sfLkc5VBFU6UkljF6... (flutter/engine#42187) 2023-05-20 [email protected] Roll Skia from 7202b405f061 to b4a4782cf89d (19 revisions) (flutter/engine#42185) 2023-05-20 [email protected] [Impeller] avoid creating multiple concurrent message loops for Andorid Vulkan (flutter/engine#42146) 2023-05-20 [email protected] Implement `ImageFilter`/`ColorFilter`/`MaskFilter` in Skwasm (flutter/engine#42088) 2023-05-20 [email protected] [Impeller] Made other vulkan objects cleanup properly. (flutter/engine#42113) 2023-05-19 [email protected] [Impeller] Fix the issue that 'coverage_coords' is incorrectly calculated in 'FillPathGeometry::GetPositionUVBuffer' (flutter/engine#42155) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from TWjmvLCOnYAU to 88pzkUAkSKsJ fuchsia/sdk/core/mac-amd64 from pwdDQgM88sqL to JU-dKW3CQIUz If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…lutter#127292) flutter/engine@aac0919...f0f3fe7 2023-05-21 [email protected] Roll Skia from 7c7dff949a27 to 5b2005e47bf3 (1 revision) (flutter/engine#42199) 2023-05-21 [email protected] Roll Fuchsia Linux SDK from gQ989rlKAuTJHQR-C... to 88pzkUAkSKsJrNG38... (flutter/engine#42198) 2023-05-21 [email protected] Roll Fuchsia Mac SDK from 868_67npyO8nD_JCx... to JU-dKW3CQIUzhbqWE... (flutter/engine#42197) 2023-05-21 [email protected] Roll Skia from a60bfcb01af9 to 7c7dff949a27 (1 revision) (flutter/engine#42195) 2023-05-20 [email protected] Roll Fuchsia Linux SDK from c_fRDyBVZX-MwW5fS... to gQ989rlKAuTJHQR-C... (flutter/engine#42194) 2023-05-20 [email protected] Roll Skia from f3e9cb7d37fd to a60bfcb01af9 (1 revision) (flutter/engine#42193) 2023-05-20 [email protected] Roll Fuchsia Mac SDK from sfLkc5VBFU6UkljF6... to 868_67npyO8nD_JCx... (flutter/engine#42191) 2023-05-20 [email protected] Move SkSurface::MakeNull to SkSurfaces::Null (flutter/engine#42158) 2023-05-20 [email protected] Roll Fuchsia Linux SDK from TWjmvLCOnYAUgAzvT... to c_fRDyBVZX-MwW5fS... (flutter/engine#42189) 2023-05-20 [email protected] Roll Skia from b4a4782cf89d to f3e9cb7d37fd (1 revision) (flutter/engine#42188) 2023-05-20 [email protected] Roll Fuchsia Mac SDK from pwdDQgM88sqLmZczj... to sfLkc5VBFU6UkljF6... (flutter/engine#42187) 2023-05-20 [email protected] Roll Skia from 7202b405f061 to b4a4782cf89d (19 revisions) (flutter/engine#42185) 2023-05-20 [email protected] [Impeller] avoid creating multiple concurrent message loops for Andorid Vulkan (flutter/engine#42146) 2023-05-20 [email protected] Implement `ImageFilter`/`ColorFilter`/`MaskFilter` in Skwasm (flutter/engine#42088) 2023-05-20 [email protected] [Impeller] Made other vulkan objects cleanup properly. (flutter/engine#42113) 2023-05-19 [email protected] [Impeller] Fix the issue that 'coverage_coords' is incorrectly calculated in 'FillPathGeometry::GetPositionUVBuffer' (flutter/engine#42155) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from TWjmvLCOnYAU to 88pzkUAkSKsJ fuchsia/sdk/core/mac-amd64 from pwdDQgM88sqL to JU-dKW3CQIUz If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
fixes flutter/flutter#127058
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.