-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix argument type in FlutterDesktopEngineGetTextureRegistrar #27522
Conversation
Why are the unit tests compiling? It seems like this should have been caught immediately by the compiler. |
They are both opaque pointers. |
Opaque pointers should be typesafe though; that's the whole point of the struct pointer construct over just making them typedefs for |
I checked, they are declared correctly. But I don't think that |
Actually, I was wrong. Because the extern "C" declaration has wrong type, the implementation inside |
Looks like I missed that this part wasn't tested when approving the PR, and I forgot that it wasn't exposed there. We should include testing in this PR, either directly of the C API, or by exposing it, so there's code compiled against it that would have caught this. |
@stuartmorgan, I added |
@@ -62,6 +62,9 @@ class FlutterEngine : public PluginRegistry { | |||
FlutterDesktopPluginRegistrarRef GetRegistrarForPlugin( | |||
const std::string& plugin_name) override; | |||
|
|||
// Returns the texture registrar for this engine. | |||
FlutterDesktopTextureRegistrarRef GetTextureRegistrar(); |
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.
We should expose a wrapper, not the raw type. The only reason the plugin registrar is the raw type is that the use case for it is to pass to a plugin registration function, which is a C API (as it's a dll interface). This should be like the messenger or the view, where the wrapper vends a wrapper.
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 don't currently have time to write a wrapper for FlutterDesktopTextureRegistrar
, nor do I think that should that be in scope of this PR. I can remove this from FlutterEngine
and just call FlutterDesktopEngineGetTextureRegistrar
somewhere, but I'm really not sure what the proper place for that would be. Any suggestion is appreciated.
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.
A direct test would a test written against the C API directly. It doesn't look like there are any at the moment, but I don't remember if there's a reason doing that is problematic, or it was just never backfilled. It may just need some build plumbing to make it possible to launch the engine from a test (IIRC that was done for macOS, but I'm not sure if Linux and Windows have it.)
@cbracken I know you have a plan around doing some more testing of the desktop embeddings; is that part of that plan?
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.
The C api is currently tested indirectly through the client wrapper. Since there's no wrapper for texture registrar yet I added a test that just calls the C API. (TEST(FlutterEngineTest, GetTextureRegistrar)
)
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.
@cbracken I know you have a plan around doing some more testing of the desktop embeddings; is that part of that plan?
That is indeed part of the plan. The person working on it has put that work on hold for the moment. You're correct that some progress was made on the macOS side of things. Filed flutter/flutter#87299 for this.
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.
@cbracken, is that something that should block this PR? It just fixes the method signature (otherwise it can't be called as the underlying implementation is not exported)
efc8608
to
bd5237c
Compare
This should be good for another review pass. |
cc @stuartmorgan @cbracken Thoughts on another review? |
FlutterDesktopEngineProperties properties; | ||
memset(&properties, 0, sizeof(FlutterDesktopEngineProperties)); | ||
auto engine = FlutterDesktopEngineCreate(&properties); | ||
auto texture_registrar = FlutterDesktopEngineGetTextureRegistrar(engine); |
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 doesn't make sense for this test to be in client_wrapper
. The purpose of the unit tests for client_wrapper are specifically to unit test the client_wrapper code, and this isn't doing that. We shouldn't put tests in places they don't belong as a workaround for not yet having the harness we should have for testing the C API surface.
Can't you write this test in the right place (a new unit test target that's part of the C API layer) by using the embedding API mock support that I added a while back to make it not need complex setup (stubbing out the underlying engine calls that would try to spin everything up)?
@knopp Any updates to Stuart's comments? |
Sorry, not yet, we talked about this on discord but I haven't had time yet to update the PR. |
b1a8771
to
2962099
Compare
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. |
@knopp should we close this PR for now? |
@Hixie, I currently don't have time to write the unit tests that @stuartmorgan requested, but the declaration is still wrong (and the symbol not exported). This is a trivial fix and it seems weird to block this on account of a missing unit test (which other parts of the API don't have either). |
We shouldn't have landed the other parts of the API that don't have tests either. |
Agreed, as noted above To add a bit more context about the history of testing in the Windows embedding: originally the desktop embeddings had ~no testing (for historical reasons; they were not originally part of Flutter). As they matured, we started filling in testing—although I certainly admit that I did not prioritize that as much as I should have. For Windows in particular, we reached a point where where:
That left a testing gap for the thin C layer, but because it was a thin layer, there wasn't a lot to test there, so the priority of setting up testing coverage of that specific was relatively low. (Especially since in almost all cases we did have compilation coverage that would have caught this issue, since we usually added the wrapper as part of the same PR that added the C API). This PR demonstrates the problem with having no direct testing of that layer, and so—as with any other bug that we find that indicates a testing gap—we need to close that gap as part of the fix. |
Is any progress on this PR likely? Can we close it? |
@cbracken Could someone on the desktop team add the test here? It's a testing gap we already wanted to close, and this API is clearly broken, so it seems worth some investment on wiring up the test. |
I'll take a look at adding the test. Agreed the change itself looks absolutely fine. |
Picking this up now. |
FlutterDesktopEngineGetTextureRegistrar is used to get the texture registrar associated with an engine object and therefore should take a FlutterDesktopEngineRef parameter. This also adds an initial unit test for the public Windows C API used to implement the C++ client wrapper. In order to fully test this API, we'll want to support test fixtures similar to what we do in the embedder API tests. See: https://github.com/flutter/engine/blob/4cc5ad0b7e3c1fe9d19d2621559786ceac9302b7/shell/platform/embedder/BUILD.gn#L187-L319 This was initially identified and fixed by @knopp in: flutter#27522 This patch replaces that one and adds the simplest possible unit test to get it landed. Fixes: flutter/flutter#86617
FlutterDesktopEngineGetTextureRegistrar is used to get the texture registrar associated with an engine object and therefore should take a FlutterDesktopEngineRef parameter. This bug was initially identified and fixed by @knopp in: flutter#27522 This patch replaces that one and adds the simplest possible unit test to get it landed. This also adds an initial unit test for the public Windows C API used to implement the C++ client wrapper. In order to fully test this API, we'll want to support test fixtures similar to what we do in the embedder API tests. See: flutter/flutter#87299 Fixes: flutter/flutter#86617
FlutterDesktopEngineGetTextureRegistrar is used to get the texture registrar associated with an engine object and therefore should take a FlutterDesktopEngineRef parameter. This bug was initially identified and fixed by @knopp in: flutter#27522 This patch replaces that one and adds the simplest possible unit test to get it landed. This also adds an initial unit test for the public Windows C API used to implement the C++ client wrapper. In order to fully test this API, we'll want to support test fixtures similar to what we do in the embedder API tests. See: flutter/flutter#87299 Fixes: flutter/flutter#86617
FlutterDesktopEngineGetTextureRegistrar is used to get the texture registrar associated with an engine object and therefore should take a FlutterDesktopEngineRef parameter. This bug was initially identified and fixed by @knopp in: flutter#27522 This patch replaces that one and adds the simplest possible unit test to get it landed. This also adds an initial unit test for the public Windows C API used to implement the C++ client wrapper. In order to fully test this API, we'll want to support test fixtures similar to what we do in the embedder API tests. See: flutter/flutter#87299 Fixes: flutter/flutter#86617
FlutterDesktopEngineGetTextureRegistrar is used to get the texture registrar associated with an engine object and therefore should take a FlutterDesktopEngineRef parameter. This bug was initially identified and fixed by @knopp in: #27522 This patch replaces that one and adds the simplest possible unit test to get it landed. This also adds an initial unit test for the public Windows C API used to implement the C++ client wrapper. In order to fully test this API, we'll want to support test fixtures similar to what we do in the embedder API tests. See: flutter/flutter#87299 Fixes: flutter/flutter#86617
Replaced by #27522; sorry for the delay in getting a test written. Was behind a few other things on my list :/ |
FlutterDesktopEngineGetTextureRegistrar is used to get the texture registrar associated with an engine object and therefore should take a FlutterDesktopEngineRef parameter. This bug was initially identified and fixed by @knopp in: flutter#27522 This patch replaces that one and adds the simplest possible unit test to get it landed. This also adds an initial unit test for the public Windows C API used to implement the C++ client wrapper. In order to fully test this API, we'll want to support test fixtures similar to what we do in the embedder API tests. See: flutter/flutter#87299 Fixes: flutter/flutter#86617
FlutterDesktopEngineGetTextureRegistrar is used to get the texture registrar associated with an engine object and therefore should take a FlutterDesktopEngineRef parameter. This bug was initially identified and fixed by @knopp in: flutter#27522 This patch replaces that one and adds the simplest possible unit test to get it landed. This also adds an initial unit test for the public Windows C API used to implement the C++ client wrapper. In order to fully test this API, we'll want to support test fixtures similar to what we do in the embedder API tests. See: flutter/flutter#87299 Fixes: flutter/flutter#86617
Fixes flutter/flutter#86617
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.