TL;DR: Offscreen surface is created on the render thread and device to host
transfer performed there before task completion on the UI thread.
While attempting to snapshot layer trees, the engine was attempting to use the
IO thread context. The reasoning was that this would be safe to do because any
textures uploaded to the GPU as a result of async texture upload would have
originated from this context and hence the handles would be valid in either
context. As it turns out, while the handles are valid, Skia does not support
this use-case because cross-context images transfer ownership of the image from
one context to another. So, when we made the hop from the UI thread to the IO
thread (for snapshotting), if either the UI or GPU threads released the last
reference to the texture backed image, the image would be invalid. This led to
such images being absent from the layer tree snapshot.
Simply referencing the images as they are being used on the IO thread is not
sufficient because accessing images on one context after their ownership has
already been transferred to another is not safe behavior (from Skia's
perspective, the handles are still valid in the sharegroup).
To work around these issues, it was decided that an offscreen render target
would be created on the render thread. The color attachment of this render
target could then be transferred as a cross context image to the IO thread for
the device to host tranfer.
Again, this is currently not quite possible because the only way to create
cross context images is from encoded data. Till Skia exposes the functionality
to create cross-context images from textures in one context, we do a device to
host transfer on the GPU thread. The side effect of this is that this is now
part of the frame workload (image compression, which dominate the wall time,
is still done of the IO thread).
A minor side effect of this patch is that the GPU latch needs to be waited on
before the UI thread tasks can be completed before shell initialization.
According to the iOS docs, implementing
`- (id)insertDictationResultPlaceholder`
```Implementation of this method is optional but can be done when you want to provide a specific rectangle for the placeholder animation while the dictation results are being processed. ```
If you do not implement this method, UIKit will insert a default placeholder of 10 whitespace characters. By overriding this, no placeholder text will be inserted. If you implement the `insertDictationResultPlaceholder`, you must implement
`- (void)removeDictationResultPlaceholder:(id)placeholder willInsertResult:(BOOL)willInsertResult`
Add a `-[FlutterViewController setFlutterViewDidRenderCallback:]`
method on iOS so client applications can be notified when the Flutter
view has rendered. This can be used for add2app cases to determine
when to take an initial screenshot for comparisons in automated
tests.
The callback is expected to be an Objective-C block (or Swift
closure). I chose to support only a single callback because it's
much simpler (especially since it does not require a separate method
to unregister the callback), and it's not clear that there are use
cases that would justify additional complexity. Clients have the
flexibility to make their callback invoke other callbacks anyway.
I alternatively considered adding a `-[FlutterViewController
viewDidRenderFirstFlutterFrame]` method that clients could override
in a subclass, but using an Objective-C block seems more flexible and
less of a burden.
Fixes https://github.com/flutter/flutter/issues/20665
The touch mapper was a relic of a time when the pointer IDs had to be less
than 16. Not respecting the touch phase is getting in the way of clients that
fake their own touches. Turns out the AppDelegate also like to fake touches to
simulate status bar events. Now, except in cases where there is a specific
override in place, the UI touch phase is respected.
Also adds //flutter/benchmarking which, similar to //flutter/testing, allows for the creation of a benchmarking executable. This is also the target that contains benchmarking utilities.
Use a screen height ratio to determine if the keyboard is onscreen or not. This is used because Android does not provide a deterministic API to detect this.
We remove the padding when the keyboard is closed and the inset is due to the hidden navigation bar, otherwise, we apply the full keyboard inset.
* Change FlutterDartProject to keep precedence when looking for the assets bundle
* Change assetsPath to fallback to mainBundle when the defined bundle does not contain assets
This shell used to serve the dual purpose of running Flutter tests as
well as optionally being able to run Flutter applications on a Mac
desktop. After all the test runner targets were consolidated
(flutter_tester), this target was no longer used to run the tests. This
target is currently only used by engine developers to test changes
quickly on the host. Even for this purpose, the Desktop embedders are
more full featured and use the stable embedder API. The presence of a
cross-platform tester target, alternatives for Desktop targets that use
the stable embedder API and the fact that this target is no longer
tested, makes having this code in the source entirely redundant.
* Make FlutterStandardCodec handle writing NSData
iOS developers can accidentally pass an `NSData` object directly to
`FlutterStandardCodec` and forget to wrap it in
`FlutterStandardTypedData`. This failure won't be caught until
runtime.
Let's make `FlutterStandardCodec` more tolerant by making it assume
that `NSData` should be treated as a binary blob and by wrapping it
automatically.
Fixes https://github.com/flutter/flutter/issues/17449
Testing Done:
* Made a sample Flutter iOS application that created a
`FlutterMethodChannel` and invoked a method using an `NSData*`
argument. Verified that the Flutter method handler received the
message and that the `MethodCall.arguments` was a `UInt8Array` that
preserved the original byte order.
* Verified that without this change, the same sample application
crashed when run in debug mode.
* Add a unit test for encoding raw NSData
* Formatting adjustments
Decouple PlatformViewsController from FlutterView.
Instead of getting a FlutterView instance, depend on the specific interfaces required by
PlatformViewsController (BinaryMessenger, TextureRegistry, and Context).
This allows using PlatformViewsControlling in the flutter/embedding
code.
* Revert "Add logging if FlutterDartProject fails to load the application kernel snapshot (#6257)"
This reverts commit 18ec58629e7d90c89ea98a82f669eaccd5f82bb3.
* Revert "Update deprecated subtags from language subtag registry. (#6280)"
This reverts commit 6e159af6f2875f517aa8734538652fe9c20f1f21.
* Revert "Add Xib splashscreen support (#6289)"
This reverts commit 9c2a3826c70f726c2fbfb2ca6a51aa8826cece30.
* Revert "Fix a compilation problem when using iPhoneOS12.0sdk(Xcode10) && clang version 7.0.0. (#6279)"
This reverts commit 911b381f71ebeab7c1099b9aacf7f1dec3022229.
To make "Engine run configuration was invalid." failures (e.g.
https://github.com/flutter/flutter/issues/20777) a bit easier to
diagnose, add some more logging to `FlutterDartProject` to verify
that snapshot assets were properly bundled.
On the iPhone X, raising the keyboard sets a bottom physical inset equal
to the keyboard height, however we previously did not zero out the bottom
physical padding. This was incorrect; when a soft keyboard is present,
it 'consumes' the safe area inset for the home indicator widget,
eliminating the need for the app to handle this at all.