79 Commits

Author SHA1 Message Date
Robert Ancell
044f2542d4
Use the term 'handler' for registering callbacks. (#18269)
This is the term used in the Dart code and which callback is more commonly used
in GLib matching the Dart code will make developers life easier.
2020-05-12 09:01:10 +12:00
Robert Ancell
ccfec72798
Fix grammar in FlBinaryCodec/FlStringCodec descriptions (#18268) 2020-05-12 09:00:36 +12:00
Robert Ancell
9ea2db5bac
Add FlMessageCodec, FlBinaryCodec, FlStringCodec (#18186)
Classs for binary message encoding/decoding that matches the ones in the Flutter services library.
2020-05-08 16:13:54 +12:00
Robert Ancell
403931ff22
Add FlValue (#18185)
FlValue is a lightweight object used to contain the value types that Flutter
uses on platform channels.
2020-05-08 13:48:41 +12:00
Robert Ancell
e5a7ca577d
Handle leak of message handle when no engine present (#18157)
* Handle leak of message handle when no engine present
* Move callback in wrong location
2020-05-08 09:05:20 +12:00
Robert Ancell
805a8874cb
Add first Linux shell tests (#18159) 2020-05-06 15:33:11 +12:00
Robert Ancell
95ecd9a405
Move G_END_DECLS that was in the wrong place (#18116) 2020-05-05 09:11:57 +12:00
Robert Ancell
180a497ee5
Support platform messages in Linux shell (#17995) 2020-05-04 17:03:04 +12:00
Robert Ancell
ae96c36c55
Replace usage of NULL with nullptr to match coding style (#18023) 2020-04-29 13:26:27 -07:00
Robert Ancell
34f516b016
Use g_warning instead of stderr (#17994) 2020-04-29 15:13:29 +12:00
Robert Ancell
fda26fc70f
Run Flutter platform tasks in GLib main loop (#17910)
Fixes https://github.com/flutter/flutter/issues/54856
2020-04-29 09:13:58 +12:00
Robert Ancell
9ece5ba789
Fix units used in Linux shell timestamps. (#17912)
GTK uses timestamps in milliseconds, Flutter wants them in microseconds.
2020-04-24 13:30:34 +12:00
Robert Ancell
12012f135c
Refactor FlutterEngine usage in Linux shell (#17363) 2020-04-24 10:30:41 +12:00
Robert Ancell
1dba1ef1f8
Add pointer events to the Linux shell (#17304) 2020-04-21 11:27:13 +12:00
stuartmorgan
dfe13788ed
Adjust the GLFW build options (#17704)
- Adds an explicit option for not building the GLFW embedding.
- Disables GLFW by default on Windows, where it's no longer the
  uploaded embedding.
- Moves the X11 pkg-config, which is only used by the GLFW embedding,
  behind the GLFW build flag.
2020-04-14 12:45:21 -07:00
Robert Ancell
b360eab6f7
Move Linux shell docstrings to headers (#17410)
Update docstrings for typos and grammar style specified in the style guide.
2020-04-14 15:41:23 +12:00
stuartmorgan
71d8edb13a
Always build GTK shell (#17634) 2020-04-11 11:50:03 -07:00
Robert Ancell
6befd4a804
Update FlDartProject to new path format (#17302)
Matches the structure used on Windows of assuming a directory format.
2020-03-31 15:25:44 -07:00
Robert Ancell
c93b67aa81
Add a Linux Shell that uses GTK for rendering. (#16977) 2020-03-24 13:26:02 -07:00
Greg Spencer
8ff6948e23
Make GetDefaultFontFamilies return a vector<string> instead of… (#16928)
On Linux, there is rarely just one default font that can reasonably be expected to be on the platform. This PR changes the GetDefaultFontFamily call to be GetDefaultFontFamilies, and it now returns a vector<string> so that the font collection code can look up all of them, and if any of them exist, add them to the fallback list.

For Linux, I supplied the list "Ubuntu", "Cantarell", "DejaVu Sans", "Liberation Sans", and "Arial", which should cover a large proportion of linux machines. For the other platforms, I supplied a list of length one, containing the one fallback font that used to be defined. On Windows, I added "Segoe UI" as a default, since that is the default system font on newer Windows.

The goal of this function is to provide at least one font family that is installed, since otherwise linux (or any platform) will just have no font at all if the default font isn't found.
2020-03-05 00:45:53 +01:00
Chinmay Garde
f7b78e001d
Remove all uses of the redundant flutter_root variable. (#16311)
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.
2020-01-31 21:49:48 -08:00
stuartmorgan
fa161274fb
Switch to an incremental runloop for GLFW (#11368)
Rather than running the runloop forever, have the API expose an incremental runloop. This allows clients to do other processing if they need it.

This allows for removing the odd construction of having knowledge of GTK event handling built into the library even though nothing in the library uses it; instead runner applications that use GTK plugins (such as FDE's testbed) can do that processing at the application level instead.
2019-08-22 11:39:00 -07:00
stuartmorgan
9f8b1d223e
Clean up Windows and Linux build output (#11324)
Final portion of reworking the names of the Linux and Windows desktop build outputs.

See flutter/flutter#38589
2019-08-21 05:53:38 -07:00
stuartmorgan
f1560e6c6e
Add _glfw versions of the GLFW desktop libraries (#11024)
Part of restructuring the artifacts to support transitioning away from
GLFW embeddings on desktop.

https://github.com/flutter/flutter/issues/38589
2019-08-15 14:41:15 -07:00
James Clarke
ff484d4f69 [Windows] Alternative Windows shell platform implementation (#9835)
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.
2019-08-14 15:52:52 -07:00
Jason Simmons
6aaf5b38df
Build the GLFW shell on Linux host builds but not target builds (#9320)
Linux targets building the embedder library may be targeting environments
that do not support GLFW and GTK.
2019-06-13 16:22:33 -07:00
stuartmorgan
8412c199a5
Enable Linux shell build (#8233)
Enables building of the GLFW shell and the related unit tests.
2019-03-29 16:34:02 -04:00
Chinmay Garde
a1a2129bc4
GN Format all files in the engine. (#8369) 2019-03-29 12:44:57 -07:00
stuartmorgan
5c99138fa8
Build GLFW from source for Linux shell (#8327)
Instead of requiring a system-level GLFW, build it from source and
statically link it into the Linux shell.
2019-03-27 20:22:50 -04:00
stuartmorgan
6d8b836777
Remove use of epoxy from Linux shell (#8334)
Simplifies the build and runtime requirements for the Linux shell.
Since the engine does GL extension lookup manually anway, an extension
loader library isn't necessary.
2019-03-27 19:24:03 -04:00
stuartmorgan
d452dd5c36
Initial import of GLFW Linux shell from FDE (#8159)
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
2019-03-20 17:15:52 -04:00
Michael Goderbauer
70a1106b50
Unify copyright lines (#6757) 2018-11-07 12:24:35 -08:00
Chinmay Garde
99b3262564
Mark the linux group testonly (#5268) 2018-05-15 13:49:42 -07:00
Chinmay Garde
17a71f6969
Build the flutter tester on Linux in the default group. (#5267) 2018-05-15 13:39:14 -07:00
Chinmay Garde
73a0014b7e
Create an empty group that the Fuchsia bots use to determine the root_out_dir. (#5265)
The Fuchsia bots seem to reference this target to figure out the root_out_directory https://fuchsia.googlesource.com/build/+/master/dart/dart_test.gni#67. Note that the presence of the flutter_tester binary location itself is not depended on. Instead, the target is used to infer the directory containing the flutter_tester after a build.

Patching the //build repository in Fuchsia would mean making the tree red till a //topaz patch lands. To avoid doing this, we add back the missing reference.
2018-05-15 12:50:10 -07:00
Chinmay Garde
58e84c8bf0
Re-land "Support multiple shells in a single process. (#4932)" (#4998)
* Re-land "Support multiple shells in a single process. (#4932)"

This reverts commit 723c7d01439da4261bc836075fb55651ce9e7f03.
2018-04-13 13:48:15 -07:00
Vyacheslav Egorov
723c7d0143
Revert "Re-land "Support multiple shells in a single process. (#4932)" (#4977)" (#4981)
This reverts commit a3327bff86800b3e654a2988fa7e6049edeb679c.
2018-04-12 18:28:55 +02:00
Chinmay Garde
a3327bff86
Re-land "Support multiple shells in a single process. (#4932)" (#4977)
This reverts commit 9199b40f2a2a6e448cd251de44e020ec3b75002d.
2018-04-11 15:41:23 -07:00
Chinmay Garde
9199b40f2a
Revert "Support multiple shells in a single process. (#4932)" (#4964)
This reverts commit 6baff4c821350bbcb64e7d029574b567f3801a1a.
2018-04-10 15:28:43 -07:00
Chinmay Garde
6baff4c821
Support multiple shells in a single process. (#4932)
* Support multiple shells in a single process.

The Flutter Engine currently works by initializing a singleton shell
instance. This shell has to be created on the platform thread. The shell
is responsible for creating the 3 main threads used by Flutter (UI, IO,
GPU) as well as initializing the Dart VM. The shell, references to task
runners of the main threads as well as all snapshots used for VM
initialization are stored in singleton objects. The Flutter shell only
creates the threads, rasterizers, contexts, etc. to fully support a
single Flutter application. Current support for multiple Flutter
applications is achieved by making multiple applications share the same
resources (via the platform views mechanism).

This scheme has the following limitations:

* The shell is a singleton and there is no way to tear it down. Once you
  run a Flutter application in a process, all resources managed by it
  will remain referenced till process termination.
* The threads on which the shell performs its operations are all
  singletons. These threads are never torn down and multiple Flutter
  applications (if present) have to compete with one another on these
  threads.
* Resources referenced by the Dart VM are leaked because the VM isn't
  shutdown even when there are no more Flutter views.
* The shell as a target does not compile on Fuchsia. The Fuchsia content
  handler uses specific dependencies of the shell to rebuild all the
  shell dependencies on its own. This leads to differences in frame
  scheduling, VM setup, service protocol endpoint setup, tracing, etc..
  Fuchsia is very much a second class citizen in this world.
* Since threads and message loops are managed by the engine, the engine
  has to know about threading and platform message loop interop on each
  supported platform.

Specific updates in this patch:

* The shell is no longer a singleton and the embedder holds the unique
  reference to the shell.
* Shell setup and teardown is deterministic.
* Threads are no longer managed by the shell. Instead, the shell is
  given a task runner configuration by the embedder.
* Since the shell does not own its threads, the embedder can control
  threads and the message loops operating on these threads. The shell is
  only given references to the task runners that execute tasks on these
  threads.
* The shell only needs task runner references. These references can be
  to the same task runner. So, if the embedder thinks that a particular
  Flutter application would not need all the threads, it can pass
  references to the same task runner. This effectively makes Flutter
  application run in single threaded mode. There are some places in the
  shell that make synchronous calls, these sites have been updated to
  ensure that they don’t deadlock.
* The test runner and the headless Dart code runner are now Flutter
  applications that are effectively single threaded (since they don’t
  have rendering concerns of big-boy Flutter application).
* The embedder has to guarantee that the threads and outlive the shell.
  It is easy for the embedder to make that guarantee because shell
  termination is deterministic.
* The embedder can create as many shell as it wants. Typically it
  creates a shell per Flutter application with its own task runner
  configuration. Most embedders obtain these task runners from threads
  dedicated to the shell. But, it is entirely possible that the embedder
  can obtain these task runners from a thread pool.
* There can only be one Dart VM in the process. The numerous shell
  interact with one another to manage the VM lifecycle. Once the last
  shell goes away, the VM does as well and hence all resources
  associated with the VM are collected.
* The shell as a target can now compile and run on Fuchsia. The current
  content handler has been removed from the Flutter engine source tree
  and a new implementation has been written that uses the new shell
  target.
* Isolate management has been significantly overhauled. There are no
  owning references to Dart isolates within the shell. The VM owns the
  only strong reference to the Dart isolate. The isolate that has window
  bindings is now called the root isolate. Child isolates can now be
  created from the root isolate and their bindings and thread
  configurations are now inherited from the root isolate.
* Terminating the shell terminates its root isolates as well as all the
  isolates spawned by this isolate. This is necessary be shell shutdown
  is deterministic and the embedder is free to collect the threads on
  which the isolates execute their tasks (and listen for mircrotasks
  flushes on).
* Launching the root isolate is now significantly overhauled. The shell
  side (non-owning) reference to an isolate is now a little state
  machine and illegal state transitions should be impossible (barring
  construction issues). This is the only way to manage Dart isolates in
  the shell (the shell does not use the C API is dart_api.h anymore).
* Once an isolate is launched, it must be prepared (and hence move to
  the ready phase) by associating a snapshot with the same. This
  snapshot can either be a precompiled snapshot, kernel snapshot, script
  snapshot or source file. Depending on the kind of data specified as a
  snapshot as well as the capabilities of the VM running in the process,
  isolate preparation can fail preparation with the right message.
* Asset management has been significantly overhauled. All asset
  resolution goes through an abstract asset resolver interface. An asset
  manager implements this interface and manages one or more child asset
  resolvers. These asset resolvers typically resolve assets from
  directories, ZIP files (legacy FLX assets if provided), APK bundles,
  FDIO namespaces, etc…
* Each launch of the shell requires a separate and fully configured
  asset resolver. This is necessary because launching isolates for the
  engine may require resolving snapshots as assets from the asset
  resolver. Asset resolvers can be shared by multiple launch instances
  in multiple shells and need to be thread safe.
* References to the command line object have been removed from the
  shell. Instead, the shell only takes a settings object that may be
  configured from the command line. This makes it easy for embedders and
  platforms that don’t have a command line (Fuchsia) to configure the
  shell. Consequently, there is only one spot where the various switches
  are read from the command line (by the embedder and not the shell) to
  form the settings object.
* All platform now respect the log tag (this was done only by Android
  till now) and each shell instance have its own log tag. This makes
  logs from multiple Flutter application in the same process (mainly
  Fuchsia) more easily decipherable.
* The per shell IO task runner now has a new component that is
  unfortunately named the IOManager. This component manages the IO
  GrContext (used for asynchronous texture uploads) that cooperates with
  the GrContext on the GPU task runner associated with the shell. The
  IOManager is also responsible for flushing tasks that collect Skia
  objects that reference GPU resources during deterministic shell
  shutdown.
* The embedder now has to be careful to only enable Blink on a single
  instance of the shell. Launching the legacy text layout and rendering
  engine multiple times is will trip assertions. The entirety of this
  runtime has been separated out into a separate object and can be
  removed in one go when the migration to libtxt is complete.
* There is a new test target for the various C++ objects that the shell
  uses to interact with the Dart VM (the shell no longer use the C API
  in dart_api.h). This allows engine developers to test VM/Isolate
  initialization and teardown without having the setup a full shell
  instance.
* There is a new test target for the testing a single shell instances
  without having to configure and launch an entire VM and associated
  root isolate.
* Mac, Linux & Windows used to have different target that created the
  flutter_tester referenced by the tool. This has now been converted
  into a single target that compiles on all platforms.
* WeakPointers vended by the fml::WeakPtrFactory(notice the difference
  between the same class in the fxl namespace) add threading checks on
  each use. This is enabled by getting rid of the “re-origination”
  feature of the WeakPtrFactory in the fxl namespace. The side effect of
  this is that all non-thread safe components have to be created, used
  and destroyed on the same thread. Numerous thread safety issues were
  caught by this extra assertion and have now been fixed.
  * Glossary of components that are only safe on a specific thread (and
    have the fml variants of the WeakPtrFactory):
    * Platform Thread: Shell
    * UI Thread: Engine, RuntimeDelegate, DartIsolate, Animator
    * GPU Thread: Rasterizer, Surface
    * IO Thread: IOManager

This patch was reviewed in smaller chunks in the following pull
requests. All comments from the pulls requests has been incorporated
into this patch:

* flutter/assets: https://github.com/flutter/engine/pull/4829
* flutter/common: https://github.com/flutter/engine/pull/4830
* flutter/content_handler: https://github.com/flutter/engine/pull/4831
* flutter/flow: https://github.com/flutter/engine/pull/4832
* flutter/fml: https://github.com/flutter/engine/pull/4833
* flutter/lib/snapshot: https://github.com/flutter/engine/pull/4834
* flutter/lib/ui: https://github.com/flutter/engine/pull/4835
* flutter/runtime: https://github.com/flutter/engine/pull/4836
* flutter/shell: https://github.com/flutter/engine/pull/4837
* flutter/synchronization: https://github.com/flutter/engine/pull/4838
* flutter/testing: https://github.com/flutter/engine/pull/4839
2018-04-10 14:57:02 -07:00
Alexander Aprelev
e582928a49
Accommodate flutter test --preview-dart-2 on windows and linux (#4564)
* Support .packages option in frontend_server, bundle_path in main_mac.

This is needed to be able to run  in  mode.

* Remove byte store tests

* Remove unused import

* Fix formatting

* Enable flutter test argument passing on win and linux.

* Fix formatting
2018-01-18 16:05:19 -08:00
P.Y. Laligand
6fcb45991d Move //dart to //third_party/dart. (#4245) 2017-10-19 01:20:38 -07:00
P.Y. Laligand
5fae5d52cf Allow the project to be mapped to a location other than //flutter. (#4203)
This is for Fuchsia where we would like it to be located at //third_party/flutter.
2017-10-13 17:00:58 -07:00
P.Y. Laligand
fc3cb8fb3b Adjust to new location of lib/tonic. (#4132) 2017-09-21 14:30:28 -07:00
George Kulakowski
6502090278 Fix remaining ftl->fxl conversions (#4091)
* Fix remaining ftl->fxl conversions

The previous scripting pass at this did not account for objective c file endings

* Update tonic DEPS reference to the post-fxl version
2017-09-11 16:31:18 -07:00
George Kulakowski
3aa7522c11 Rename ftl to fxl in Fuchsia specific code (#4090) 2017-09-11 15:58:48 -07:00
Adam Barth
73554a1c32 Add //garnet (#4043)
This repository contains FTL now in the Fuchsia build.
2017-08-31 16:47:13 -07:00
Adam Barth
9cfc67ef57 Retrieve the last error from the proper thread (#3649)
Previously, the last error was a global static. Now it is a thread-specific
value, which means we need to visit the UI thread to read the value.
2017-05-04 21:30:39 -07:00
Adam Barth
da0b1f5a36 Make microtask queue be per thread (#3644)
Previously, it was a static. Doesn't have much effect in practice because we
only use this microtask queue for main isolates, which exist on a single
thread.
2017-05-04 15:06:43 -07:00
Ryan Macnak
1fed16fb25 Adjust GN for removal of libdart, take two. (#3584)
Update targets only included in host_debug_unopt.
2017-04-11 09:52:54 -07:00