1. 11 4月, 2018 1 次提交
    • C
      Support multiple shells in a single process. (#4932) · 6baff4c8
      Chinmay Garde 提交于
      * 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
      6baff4c8
  2. 16 11月, 2017 1 次提交
  3. 10 11月, 2017 1 次提交
  4. 02 11月, 2017 1 次提交
  5. 01 11月, 2017 1 次提交
  6. 13 10月, 2017 1 次提交
  7. 15 9月, 2017 1 次提交
  8. 12 9月, 2017 1 次提交
  9. 02 9月, 2017 1 次提交
  10. 30 3月, 2017 1 次提交
    • C
      Cleanup timeline markers. (#3540) · 0451dc11
      Chinmay Garde 提交于
      * Name the platform thread in the timeline. This does not affect (nor is it affected by) the pthread name set by the embedder.
      * Make it easier in the timeline to see not only when the frame was request, but also when that frame request was fulfilled.
      * Trace message loop wakes.
      0451dc11
  11. 25 10月, 2016 1 次提交
  12. 12 10月, 2016 1 次提交
  13. 24 9月, 2016 1 次提交
    • C
      Move shell to //flutter and split shell/BUILD.gn into smaller pieces for each subcomponent. (#3053) · 9eb446e0
      Chinmay Garde 提交于
      * Namespaces have been updated to reflect the move from //flutter/sky/shell to //flutter/shell.
      * shell/BUILD.gn file has been split into smaller GN files for each subcomponent of the shell (common, GPU, diagnostic, testing).
      * GN dependencies have been rewritten to stop exposing common shell dependencies as public. Duplicates have also been removed.
      * GPU subcomponent has been updated make it more suitable for Vulkan integration.
      * The GLFW backend has been resurrected.
      9eb446e0
  14. 31 8月, 2016 1 次提交
  15. 24 8月, 2016 1 次提交
  16. 20 8月, 2016 2 次提交
  17. 19 8月, 2016 1 次提交
  18. 13 8月, 2016 1 次提交
    • A
      Rename SkyView to RuntimeController (#2924) · b2058f8b
      Adam Barth 提交于
      Also, rename SkyViewClient to RuntimeDelegate. These names are more
      sensible.
      
      This patch also cleans up the RuntimeDelegate a bit, for example by
      removing support for flushing real-time events, which aren't used.
      b2058f8b
  19. 10 8月, 2016 1 次提交
  20. 09 8月, 2016 1 次提交
  21. 02 8月, 2016 1 次提交
  22. 28 5月, 2016 1 次提交
    • A
      Roll mojo2 (#2722) · b6ad8850
      Adam Barth 提交于
      * Update to mojo 7d579155cc597aa3befcbfad66eef54bda06b57c
      
      * Update to new API
      b6ad8850
  23. 21 4月, 2016 1 次提交
  24. 03 3月, 2016 1 次提交
  25. 29 1月, 2016 2 次提交
  26. 12 12月, 2015 1 次提交
  27. 03 12月, 2015 1 次提交
  28. 26 11月, 2015 1 次提交
    • A
      Flutter for Modroid should use vsync · 97a375f0
      Adam Barth 提交于
      This patch teaches Flutter how to connect to the vsync service on Modroid.
      Also, remove our now-redunant copy of vsync.mojom.
      
      Fixes #589
      97a375f0
  29. 30 7月, 2015 1 次提交
    • A
      Improve vsync provider · 752ff897
      Adam Barth 提交于
      Now we actually use the vsync signal to trigger work. Previously, we'd hit the
      pipeline depth limit too early and fall back to swap buffers-triggered
      rendering.
      
      Also, rename Vsync to VSync on recommendation from jamesr.
      752ff897
  30. 29 7月, 2015 3 次提交
    • A
      Drive frames from the vsync provider on Android · f81d96e1
      Adam Barth 提交于
      Instead of using back pressure from swap buffers to drive the engine, this
      patch using the vsync signal from the Android framework. We still respect
      back pressure from swap buffers if we get too far ahead.
      f81d96e1
    • A
      Improve pipeline accounting · a836ce05
      Adam Barth 提交于
      Previously, there was a race condition whereby we could end up with three
      requests in the pipeline. Now we update the number of outstanding requests
      synchronously, which avoids the race.
      a836ce05
    • A
      Increase the graphics pipeline depth to 2 · c1f0e35e
      Adam Barth 提交于
      Previously, we weren't overlapping any work between the UI and the GPU threads
      because each waited for the other to finish. After this patch, we now have a
      pipeline depth of 2, which means we can be working on two frames at once, one
      for each thread.  In the future, we should dynamically adjust the pipeline
      depth.
      c1f0e35e
  31. 17 7月, 2015 1 次提交
  32. 11 7月, 2015 1 次提交
  33. 26 2月, 2015 1 次提交
    • E
      Make WebView::close not crash and start to fix navigation in SkyShell · 3d09314b
      Eric Seidel 提交于
      However WebView::close() no longer crashes.  close() is never called
      in MojoShell since mojo can't shutdown yet.
      
      I tried closing the existing WebView and replacing it
      but somehow that caused it to only draw red.  After a while
      of looking at this with abarth we decided to just load into
      the same WebView for now.
      
      Eventually we should do something smarter where we start the
      provisional load and only replace the webview once the new one is
      ready, but that's a later CL.
      
      R=abarth@chromium.org
      BUG=
      
      Review URL: https://codereview.chromium.org/952273003
      3d09314b
  34. 19 2月, 2015 1 次提交