gaaclarke dab253347f [Impeller] introduces DeviceHolder to avoid accessing a dead Device (flutter/engine#41748)
An alternative to https://github.com/flutter/engine/pull/41527

This introduces a new protocol called `DeviceHolder` whose only purpose is to return a pointer to a device.  That way people can hold onto weak_ptr's to the `DeviceHolder` and know to abort further work once the Device is deleted (like loading pipelines on a background thread).  This PR also changes the return type of ContextVK::GetDevice from returning a reference to a pointer as a hope to better communicate what is happening and discourage copying of the vk::Device.

I would actually recommend abolishing holding onto instance variables of the vk::Device since it isn't clear that that is just a raw pointer.  That's sort of how we got into this problem.

fixes https://github.com/flutter/flutter/issues/125522
fixes https://github.com/flutter/flutter/issues/125519
~~fixes https://github.com/flutter/flutter/issues/125571~~

Testing: Fixes flake in existing tests.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2023-05-09 00:11:05 +00:00
..