1. 03 9月, 2019 1 次提交
    • J
      [Windows] Update API for alternative Windows shell platform implementation (#11327) · 51a376d7
      James Clarke 提交于
      * Begin API evolution to a more native win32 API
      
      * Child-window based hosting
      
      * Plumb through an initial size for child window to avoid reallocated surface on start
      
      * Windows API cleanup part 1
      
      * Fix wrapper tests
      
      * Ensure flutter's HWND resources are destroyed
      
      * Final API cleanup
      
      * Fix dynamic DPI handling
      
      * Cleanup
      
      * Fix a bug that was causing engine to not be shutdown correctly
      
      * CR feedback
      
      * auto format
      
      * CR feedback: combine FlutterView and FlutterViewController
      
      * The one that clang-format seems to always get wrong
      
      * expletive
      
      * fix sources for licesnse file
      
      * CR Feedback
      
      * cleanup
      
      * Update GetNativeWindow() to return an HWND rather than a long
      
      * fix formatting
      51a376d7
  2. 31 8月, 2019 1 次提交
  3. 27 8月, 2019 2 次提交
  4. 24 8月, 2019 1 次提交
  5. 23 8月, 2019 4 次提交
    • K
      Make message loop task entry containers thread safe (#11367) · 632a37b5
      Kaushik Iska 提交于
      The core underlying issue is that vector push_back could re-allocate and cause us to segfault. I have switched the backing queues to a map per @jason-simmons suggestion in flutter/flutter#38778.
      
      I've also added a test to capture the aforementioned bug. I've run internal tests several times to validate that this is fixed.
      
      General threading note for this class is that only the following operations take a write lock on the meta mutex:
      
      1. Create
      2. Dispose
      
      The rest of the operations take read lock on the meta mutex and acquire finer grained locks for the duration of the operation. We can not grab read lock for the entire duration of NotifyObservers for example because observer can in-turn create other queues -- Which we should not block.
      
      Additional changes:
      
      1. Make as many methods as possible const. Unlocked methods are all const.
      2. Migrate all the queue members to a struct, and have a map.
      3. Get rid of the un-used Swap functionality.
      632a37b5
    • C
      fcc158fd
    • Y
      sync web engine; run web engine tests (#11031) · fad38e25
      Yegor 提交于
      sync web engine; run web engine tests
      fad38e25
    • G
  6. 21 8月, 2019 2 次提交
  7. 16 8月, 2019 1 次提交
  8. 15 8月, 2019 2 次提交
    • S
      Rename macOS FLE* classes to Flutter* (#11010) · c3e9c145
      stuartmorgan 提交于
      Renames all FLE* classes in the macOS embedding to Flutter*. With the exception
      of -[FlutterDartProject engineSwitches], which is very clearly called out in the
      comment, the APIs should be stable at this point, so the marker prefix is no
      longer needed.
      
      This is a breaking change for macOS embedders, but going forward breaking
      changes at the source level for the macOS API should now be rare.
      
      Some of these classes will likely merge with the iOS versions in the future (e.g.,
      FlutterDartProject), but that will be an implementation detail that will not affect
      clients.
      
      Fixes flutter/flutter#31735
      c3e9c145
    • J
      [Windows] Alternative Windows shell platform implementation (#9835) · ff484d4f
      James Clarke 提交于
      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.
      ff484d4f
  9. 14 8月, 2019 2 次提交
    • C
      Allow embedder controlled composition of Flutter layers. (#10195) · e8f95440
      Chinmay Garde 提交于
      This patch allows embedders to split the Flutter layer tree into multiple
      chunks. These chunks are meant to be composed one on top of another. This gives
      embedders a chance to interleave their own contents between these chunks.
      
      The Flutter embedder API already provides hooks for the specification of
      textures for the Flutter engine to compose within its own hierarchy (for camera
      feeds, video, etc..). However, not all embedders can render the contents of such
      sources into textures the Flutter engine can accept. Moreover, this composition
      model may have overheads that are non-trivial for certain use cases. In such
      cases, the embedder may choose to specify multiple render target for Flutter to
      render into instead of just one.
      
      The use of this API allows embedders to perform composition very similar to the
      iOS embedder. This composition model is used on that platform for the embedding
      of UIKit view such and web view and map views within the Flutter hierarchy.
      However, do note that iOS also has threading configurations that are currently
      not available to custom embedders.
      
      The embedder API updates in this patch are ABI stable and existing embedders
      will continue to work are normal. For embedders that want to enable this
      composition mode, the API is designed to make it easy to opt into the same in an
      incremental manner.
      
      Rendering of contents into the “root” rendering surface remains unchanged.
      However, now the application can push “platform views” via a scene builder.
      These platform views need to handled by a FlutterCompositor specified in a new
      field at the end of the FlutterProjectArgs struct.
      
      When a new platform view in introduced within the layer tree, the compositor
      will ask the embedder to create a new render target for that platform view.
      Render targets can currently be OpenGL framebuffers, OpenGL textures or software
      buffers. The type of the render target returned by the embedder must be
      compatible with the root render surface. That is, if the root render surface is
      an OpenGL framebuffer, the render target for each platform view must either be a
      texture or a framebuffer in the same OpenGL context. New render target types as
      well as root renderers for newer APIs like Metal & Vulkan can and will be added
      in the future. The addition of these APIs will be done in an ABI & API stable
      manner.
      
      As Flutter renders frames, it gives the embedder a callback with information
      about the position of the various platform views in the effective hierarchy.
      The embedder is then meant to put the contents of the render targets that it
      setup and had previously given to the engine onto the screen (of course
      interleaving the contents of the platform views).
      
      Unit-tests have been added that test not only the structure and properties of
      layer hierarchy given to the compositor, but also the contents of the texels
      rendered by a test compositor using both the OpenGL and software rendering
      backends.
      
      Fixes b/132812775
      Fixes flutter/flutter#35410
      e8f95440
    • D
      Revert "Track detailed LibTxt metrics with LineMetrics(#10127)" (#10982) · da352d0f
      Dan Field 提交于
      This reverts commit 8682aaf4.
      da352d0f
  10. 13 8月, 2019 1 次提交
    • K
      Allow for dynamic thread merging on IOS for embedded view mutations (#9819) · 971a6391
      Kaushik Iska 提交于
      After pre-roll we know if there have been any mutations made to the IOS embedded UIViews. If there are any mutations and the thread configuration is such chat the mutations will be committed on an illegal thread (GPU thread), we merge the threads and keep them merged until the lease expires. The lease is currently set to expire after 10 frames of no mutations. If there are any mutations in the interim we extend the lease.
      
      TaskRunnerMerger will ultimately be responsible for enforcing the correct thread configurations.
      
      This configuration will be inactive even after this change since still use the same thread when we create the iOS engine. That is slated to change in the coming PRs.
      971a6391
  11. 10 8月, 2019 4 次提交
  12. 09 8月, 2019 1 次提交
  13. 07 8月, 2019 1 次提交
  14. 06 8月, 2019 1 次提交
  15. 03 8月, 2019 1 次提交
  16. 01 8月, 2019 1 次提交
  17. 30 7月, 2019 1 次提交
  18. 27 7月, 2019 1 次提交
  19. 23 7月, 2019 1 次提交
  20. 20 7月, 2019 1 次提交
  21. 18 7月, 2019 1 次提交
  22. 16 7月, 2019 1 次提交
  23. 13 7月, 2019 1 次提交
    • K
      Add the functionality to merge and unmerge MessageLoopTaskQueues (#9436) · 379028ab
      Kaushik Iska 提交于
      - Add the functionality to merge and unmerge MessageLoopTaskQueues
      
      This introduces a notion of a "owning" and "subsumed" queue ids.
      Owning queue will take care of the tasks submitted to both that and it's
      subsumed queue.
      
      - The tasks submitted still maintain the queue affinity
      - Same for the task observers
      
      - Also adds MergedQueuesRunner which grabs both the locks owner
        and subsumed queues in RAII fashion.
      
      - Also use task queue id to verify if we are running
        in the same thread.
      
      - This is to enable merging the backed message loop task
        queues to enable dynamic thread merging in IOS.
      379028ab
  24. 12 7月, 2019 2 次提交
  25. 11 7月, 2019 4 次提交
  26. 10 7月, 2019 1 次提交
    • C
      Rework image & texture management to use concurrent message queues. (#9486) · ad582b50
      Chinmay Garde 提交于
      This patch reworks image decompression and collection in the following ways
      because of misbehavior in the described edge cases.
      
      The current flow for realizing a texture on the GPU from a blob of compressed
      bytes is to first pass it to the IO thread for image decompression and then
      upload to the GPU. The handle to the texture on the GPU is then passed back to
      the UI thread so that it can be included in subsequent layer trees for
      rendering. The GPU contexts on the Render & IO threads are in the same
      sharegroup so the texture ends up being visible to the Render Thread context
      during rendering. This works fine and does not block the UI thread. All
      references to the image are owned on UI thread by Dart objects. When the final
      reference to the image is dropped, the texture cannot be collected on the UI
      thread (because it has not GPU context). Instead, it must be passed to either
      the GPU or IO threads. The GPU thread is usually in the middle of a frame
      workload so we redirect the same to the IO thread for eventual collection. While
      texture collections are usually (comparatively) fast, texture decompression and
      upload are slow (order of magnitude of frame intervals).
      
      For application that end up creating (by not necessarily using) numerous large
      textures in straight-line execution, it could be the case that texture
      collection tasks are pending on the IO task runner after all the image
      decompressions (and upload) are done. Put simply, the collection of the first
      image could be waiting for the decompression and upload of the last image in the
      queue.
      
      This is exacerbated by two other hacks added to workaround unrelated issues.
      * First, creating a codec with a single image frame immediately kicks of
        decompression and upload of that frame image (even if the frame was never
        request from the codec). This hack was added because we wanted to get rid of
        the compressed image allocation ASAP. The expectation was codecs would only be
        created with the sole purpose of getting the decompressed image bytes.
        However, for applications that only create codecs to get image sizes (but
        never actually decompress the same), we would end up replacing the compressed
        image allocation with a larger allocation (device resident no less) for no
        obvious use. This issue is particularly insidious when you consider that the
        codec is usually asked for the native image size first before the frame is
        requested at a smaller size (usually using a new codec with same data but new
        targetsize). This would cause the creation of a whole extra texture (at 1:1)
        when the caller was trying to “optimize” for memory use by requesting a
        texture of a smaller size.
      * Second, all image collections we delayed in by the unref queue by 250ms
        because of observations that the calling thread (the UI thread) was being
        descheduled unnecessarily when a task with a timeout of zero was posted from
        the same (recall that a task has to be posted to the IO thread for the
        collection of that texture). 250ms is multiple frame intervals worth of
        potentially unnecessary textures.
      
      The net result of these issues is that we may end up creating textures when all
      that the application needs is to ask it’s codec for details about the same (but
      not necessarily access its bytes). Texture collection could also be delayed
      behind other jobs to decompress the textures on the IO thread. Also, all texture
      collections are delayed for an arbitrary amount of time.
      
      These issues cause applications to be susceptible to OOM situations. These
      situations manifest in various ways. Host memory exhaustion causes the usual OOM
      issues. Device memory exhaustion seems to manifest in different ways on iOS and
      Android. On Android, allocation of a new texture seems to be causing an
      assertion (in the driver). On iOS, the call hangs (presumably waiting for
      another thread to release textures which we won’t do because those tasks are
      blocked behind the current task completing).
      
      To address peak memory usage, the following changes have been made:
      * Image decompression and upload/collection no longer happen on the same thread.
        All image decompression will now be handled on a workqueue. The number of
        worker threads in this workqueue is equal to the number of processors on the
        device. These threads have a lower priority that either the UI or Render
        threads. These workers are shared between all Flutter applications in the
        process.
      * Both the images and their codec now report the correct allocation size to Dart
        for GC purposes. The Dart VM uses this to pick objects for collection. Earlier
        the image allocation was assumed to 32bpp with no mipmapping overhead
        reported. Now, the correct image size is reported and the mipmapping overhead
        is accounted for. Image codec sizes were not reported to the VM earlier and
        now are. Expect “External” VM allocations to be higher than previously
        reported and the numbers in Observatory to line up more closely with actual
        memory usage (device and host).
      * Decoding images to a specific size used to decode to 1:1 before performing a
        resize to the correct dimensions before texture upload. This has now been
        reworked so that images are first decompressed to a smaller size supported
        natively by the codec before final resizing to the requested target size. The
        intermediate copy is now smaller and more promptly collected. Resizing also
        happens on the workqueue worker.
      * The drain interval of the unref queue is now sub-frame-interval. I am hesitant
        to remove the delay entirely because I have not been able to instrument the
        performance overhead of the same. That is next on my list. But now, multiple
        frame intervals worth of textures no longer stick around.
      
      The following issues have been addressed:
      * https://github.com/flutter/flutter/issues/34070 Since this was the first usage
        of the concurrent message loops, the number of idle wakes were determined to
        be too high and this component has been rewritten to be simpler and not use
        the existing task runner and MessageLoopImpl interface.
      * Image decoding had no tests. The new `ui_unittests` harness has been added
        that sets up a GPU test harness on the host using SwiftShader. Tests have been
        added for image decompression, upload and resizing.
      * The device memory exhaustion in this benchmark has been addressed. That
        benchmark is still not viable for inclusion in any harness however because it
        creates 9 million codecs in straight-line execution. Because these codecs are
        destroyed in the microtask callbacks, these are referenced till those
        callbacks are executed. So now, instead of device memory exhaustion, this will
        lead to (slower) exhaustion of host memory. This is expected and working as
        intended.
      
      This patch only addresses peak memory use and makes collection of unused images
      and textures more prompt. It does NOT address memory use by images referenced
      strongly by the application or framework.
      ad582b50