Makes InvokeMethod's reply a high-level response object, rather than
binary data, matching the abstraction level of the class (and the other
languages' implementations).
In support of that:
- Adds the logic to the codecs to decode response envelopes, which had
never been implemented.
- Adds a convience implementation of MethodResult that forwards to
lambdas, so that one-off invocation handlers are easier to write.
Also simplified BinaryMessenger's API so that subclasses only need to
implement one version of Send, rather than two almost-identical versions.
Fixes https://github.com/flutter/flutter/issues/53223
Relands #17489 with a fix for the unit test flake.
The previous unit test relied on the new instance not being created at the same memory address, which isn't guaranteed.
Seems to have triggered flaky failures on the Windows bot since landing.
Example failure:
[ RUN ] PluginRegistrarTest.ManagerRemovesOnDestruction
c:\b\s\w\ir\cache\builder\src\flutter\shell\platform\common\cpp\client_wrapper\plugin_registrar_unittests.cc(149): error: Expected: (manager->GetRegistrar<PluginRegistrar>(dummy_registrar_handle)) != (first_wrapper), actual: 000002400A90E3D0 vs 000002400A90E3D0
This reverts commit 478a7855943d81a58dd9e9037fb338d3a18bb294.
This makes two changes:
- Adds a way to register a callback for when a FlutterDesktopPluginRegistrarRef is destroyed, and implements the logic to call it in the Windows and Linux embeddings.
- Adds a class to the C++ wrapper that handles making a singleton owning PluginRegistrar wrappers, and destroying them when the underlying reference goes away, to avoid needing that boilerplate code in every plugin's source.
Fixes https://github.com/flutter/flutter/issues/53496
The JSON codec is awkward to use in the wrapper (since the client has to build and link one of the JSON libraries to do so). Since it would be very cumbersome to wrap in a C API, and there's essentially no reason to use it instead of the standard codec, this removes it from the wrapper entirely.
Since some system channels (internal to the engine) still use it, it's moved into common/cpp instead of being eliminated entirely. Internally we always use RapidJSON though, so the jsoncpp implementation is removed. Also adds some unit test coverage, since there wasn't any.
Fixes#30669
Currently every Linux runner has this code to allow relative resource paths; this moves it into the framework so that any embedder can get this behavior without that code needing to be in the template.
Rolls buildroot to pick up std::filesystem support in our libc++
MethodChannel and BasicMessageChannel in the C++ wrapper didn't have the
expected semantics that passing a null handler would remove any existing
handler. This was inconsistent with other platforms and with the
lower-level object APIs in this wrapper, and made unregistration in
cases where that's desirable more difficult due to needing to keep other
object references.
Adds tests for this functionality, and some backfill of missing tests
for basic handler behavior.
See https://github.com/flutter/flutter/issues/51207
Targeted suppression of some deprecation warnings that are build errors under
clang:
- Ignore the deprecation of codecvt's unicode conversion until we decide on
a replacement strategy.
- Allow the deprecated posix names of functions in third_party/txt.
Part of https://github.com/flutter/flutter/issues/16256
This was only necessary when the Engine had to build in multiple buildroots
where the sources where checked out at different paths relative to the
buildroot. This is no longer the case and there are already cases GN rules
have been written that mix and match variable usage with the direct
specification of the path to the Flutter sources relative to the sole buildroot.
* Support empty strings and vectors in standard codec
Fixes#41993
Currently an empty string or vector will call through to WriteBytes
which asserts that the number of bytes it is being asked to write is
strictly positive. Instead we should not call WriteBytes if the length
is zero.
Similarly, when we read, we don't need to call out if the length is
zero.
* fix typo in test name
* remove unnecessary length check in ReadValue for List
* we also don't need this check before calling read as memcpy can handle size 0
Makes the plugin registration structure consistent with macOS. This will
be used in generated plugin registrant files rather than a specific
implemenation class, so this helps unblock the creation of generated
registrants on Windows and Linux.
Significantly improves the behavior of non-ASCII text input on Windows. Correctly
processes incoming character events as UTF-16, and for now uses UTF-32 for
the text model so that the existing index-based logic will work much more often.
Future work is still needed, but this will handle far more cases correctly.
In generated text fixture location lookup code:
When the second argument to write_file() is a list, it is written one
item per line to the path specified by the first argument. This ensures
that we emit a trailing newline at EOF to comply with -Wnewline-eof.
Elsewhere:
Lack of a newline at EOF was undefined behaviour prior to C++11. The
Fuchsia tree sets -Wnewline-eof in its buildroot, so we plan to do the
same. This cleans up remaining first-party C++ sources that don't
include a trailing newline.
Start work on flutter/flutter#30726 by adding an alternative win32 shell platform implementation for Windows that is not based on GLFW and that uses LIBANGLE for rendering and native win32 windowing and input. This change does not replace the GLFW implementation but rather runs side by side with it producing a secondary flutter_windows_win32.dll artifact. The following items must be added to attain parity with the GLFW implementation:
- Custom task scheduling
- Support for keyboard modifier keys
- Async texture uploads
- Correct high DPI handling on Windows versions < 1703
and will be added in subsequent changes.
embedder.h is a C API, so has no namespace, and only uses 'Flutter' as a
prefix for most symbol names. This creates potential collisions with
other code; for instance, FlutterEngine is the name of a type in
embedder.h, but also an ObjC class in the iOS Flutter API.
This adds a macro that can be set to prefix symbol names, allowing
clients (notably, the macOS embedding) to adjust the names used by the
embedding API internally without breaking ABI or API compatibility for
the standard engine build.
Currently the macro is only applied to FlutterEngine, since that's the
symbol that is currently at issue, but it can be expanded to other
symbols in the future.
* Allow specifying both Dart and non-Dart fixtures in engine unittests.
This fixes numerous issues in the way in which fixtures were managed
in the engine unit-tests.
* Instead of only being able to specify Dart fixtures, unit-tests may specify
non-Dart fixtures as well. These are simply copied over to the fixtures
directory known to the unit-test at runtime.
* An issue where numerous Dart files could be given to the kernel snapshotter
has been addressed. It was anticipated that such a (legal) invocation to the
kernel snapshotter would produce a snapshot with the contents of all the Dart
files added to the root library. This is incorrect and the behavior in this
case is undefined.
* Dart files referenced by the main Dart file are correctly tracked via a
depfile.
* The snapshotter arguments have been cleaned up to get rid of unused
arguments (`—strong`) and the use of the VM product mode argument has been
corrected to no longer depend on the Flutter product mode.
Corects a bnuch of typeos throughout teh engien codebsae. Also makes
a couple minor Commonwealth -> US spelling adjustments for consistency
with the rest of Flutter's codebase.
Made use of `misspell` tool:
https://github.com/client9/misspell
- Makes json_method_codec.cc compatible with the last stable RapidJSON release.
- Allows removing the GTK dependency with a compile flag.
- Fixes a missing break in a switch flagged by some toolchains.
Plugins may need to be able to access functions affecting the GLFW
window (e.g., a plugin to resize the window). This restructures the API
to create a distinction at both the C and C++ level between the window
controller, which provides access to high-level behaviors driving the
Flutter application, and the window, which provides access to functions
to affect the UI state of the window (i.e., wrapped GLFWwindow
functions).
Also provides a PluginRegistrar extension for plugins that need access
to GLFW-specific functionality.
Adds StandardMethodCodec support to the C++ client wrapper. This makes it
substantially easier to add Windows and Linux support for existing plugins, as
StandardMethodCodec is the default plugin protocol.
Fixesflutter/flutter#30670
Does not include extensibility for the codec, which will be added later.
Adds a type that can hold any of the types corresponding to the Dart types
that are supported by the standard message channel codec. This provides
the foundation for adding standard message codec support for the C++
desktop shells (flutter/flutter#30670).
Changes include:
- File structure
- Header guards
- Include paths
- Namespaces
- Integration with the engine's GN build
- Conversion from jsoncpp to rapidjson
- Style and clang-format adjustment to match engine repository