178 Commits

Author SHA1 Message Date
Dan Field
aea0d7a651
test scenario_app on CI (#10065) 2019-07-26 15:59:18 -07:00
gaaclarke
a4778eafb1
Removed unnecessary call to find the App.framework. (#10178) 2019-07-26 12:17:22 -07:00
gaaclarke
2dc03ab517
Added integration test that tests that the first frame callback is called (#10145) 2019-07-26 10:33:24 -07:00
gaaclarke
250ee31649
Started linking the test targets against Flutter. (#10128)
I tried to get this in quick without tests to avoid future
conflicts and wasted time reimplementing the same thing.
2019-07-25 13:41:16 -07:00
Dan Field
a0ec52886b
Embedding testing app (#10007) 2019-07-23 12:41:03 -07:00
Michael Klimushyn
8ed5da8b65
Add working Robolectric tests (#9954)
`gclient sync` now grabs Robolectric, JUnit, and their transitive
runtime dependencies. They're being stored in a new CIPD package,
`flutter/android/robolectric_bundle`.

`shell/platform/android/BUILD.gn` has a new target for building the
tests, `robolectric_tests`. `testing/run_tests.py` has been extended to
build and run the new target. Runs the android tests under
"build_and_test_android" on CI.

This also adds some very simple sample tests to start with and a README
to the java tests directory.
2019-07-23 09:06:19 -07:00
Jason Simmons
8fda1c99b1
Fix return type of assert function in gradient_test (#9961) 2019-07-19 18:55:48 -07:00
Jason Simmons
736c28b359
Update Dart engine tests to check for assertion failures only when running in debug mode (#9959) 2019-07-19 18:27:16 -07:00
Jason Simmons
da0fcf8284
Updates to the engine test runner script (#9934)
* Use separate filters for engine executables and Dart test scripts
* Do not run the benchmarks on Cirrus
2019-07-19 17:00:18 -07:00
Jason Simmons
48b1340ad7
Fix the geometry test to reflect that OffsetBase comparison operators are a partial ordering (#9925) 2019-07-19 12:59:27 -07:00
gaaclarke
3d7f93a2e7
Removed logic from FlutterAppDelegate into FlutterPluginAppLifeCycleDelegate (#9893)
Removed logic from FlutterAppDelegate into
FlutterPluginAppLifeCycleDelegate.  This is a better place for
add-to-app since it doesn't require them to use our app delegate.
2019-07-19 10:58:39 -07:00
Jason Simmons
9e0477643e
Update the exception thrown for invalid data in the codec test (#9929) 2019-07-18 15:54:32 -07:00
Jason Simmons
f20e9350d2
Fix failure of the onReportTimings window hook test (#9923) 2019-07-18 14:42:33 -07:00
Chinmay Garde
9eed783e94
Selectively enable tests that work on Windows and file issues for ones that don't. (#9852)
This is in preparation for the  tryjobs to run these tests. The LUCI harness will also be updated so that the tests to run are specified in the repo instead of the recipe.
2019-07-16 13:30:57 -07:00
Chinmay Garde
a59b6a6e38
Convert run_tests to python, allow running on Mac/Windows and allow filters for tests. (#9818)
Sample usage:

To run only the embedder_unittests in the engine with the profile variant, the command would be
```
./flutter/testing/run_tests.py --variant host_profile_unopt --type engine --filter embedder_unittests
``

To run only the geometry in Dart with the debug variant, the command would be
```
./flutter/testing/run_tests.py --variant host_debug_unopt --type dart --filter geometry_test
``

Without any argument, the behavior is identical to `run_tests.sh`.

In a subsequent patch, I will enable running unit-tests on Windows in the tryjobs. The lack of compatibility of the shell script on Windows made it so that we never ran any Windows unit-tests in the tryjobs.
2019-07-15 17:46:36 -07:00
gaaclarke
78a8ca0f62
Made Picture::toImage happen on the IO thread with no need for an onscreen surface. (#9813)
Made Picture::toImage happen on the IO thread with no need for a surface.
2019-07-15 17:16:20 -07:00
Dan Field
d1dcd18486
Remove breaking asserts (#9797) 2019-07-11 16:46:54 -07:00
gaaclarke
3b944102a5
Un-deprecated FlutterViewController's binaryMessenger. (#9767)
Un-deprecated FlutterViewController's binaryMessenger.  Leaving it as
a valid convenience method and to help minimize a breaking change.
2019-07-11 10:04:26 -07:00
Chinmay Garde
aca0482362
Make all shell unit tests use the OpenGL rasterizer. (#9746)
The software backend was used earlier.
2019-07-10 13:47:56 -07:00
Dan Field
56885f79b8
Let pushColorFilter accept all types of ColorFilters (#9641) 2019-07-10 12:06:58 -07:00
Chinmay Garde
ad582b5089
Rework image & texture management to use concurrent message queues. (#9486)
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.
2019-07-09 14:59:34 -07:00
Dan Field
887e052333
Refactor ColorFilter to have a native wrapper (#9668) 2019-07-08 15:36:16 -07:00
Yegor
94bb7a7ff2
Adds API for retaining intermediate engine layers (#9461)
Add new optional named oldLayer arguments to all push* methods of the SceneBuilder class.

When not null oldLayer signals to the engine that the intent is to update a layer rendered in a previous frame. The engine may optionally use that signal to reuse the resources allocated for that layer in the previous frame. For example, on the Web we can reuse existing DOM nodes and some of their properties and move fewer nodes around the tree.

The return type of each push method has been tightened up. Instead of having all methods return the same EngineLayer type, each method has its own unique layer type, e.g. OffsetEngineLayer. oldLayer parameters match the returned type. This prevents the framework (and other developers using dart:ui directly) from accidentally supplying an engine layer of the wrong type.
2019-06-28 12:56:03 -07:00
gaaclarke
50a8e73615
Has a binary messenger (#9419)
Made the engine and the view controllers have BinaryMessengers, not be
BinaryMessengers.  This allows us to break retain cycles and makes the
leaking channels we have not less dire.
2019-06-27 17:25:32 -07:00
Chinmay Garde
7483665e6c
Re-enable embedder_unittests. (#9482)
This was disabled in https://github.com/flutter/engine/pull/6798 waiting for
a Dart SDK patch to land e6d3a45b6a
which has long since been addressed.
2019-06-27 16:49:22 -07:00
Chinmay Garde
7b9f59efd6
Run benchmarks on try jobs. (#9493)
Fixes https://github.com/flutter/flutter/issues/35089.

These runs only ensure that the benchmark harnesses are valid. No information should be collected on the trybots because the environments are not consistent and the builds are not optimized.
2019-06-27 14:11:02 -07:00
gaaclarke
13145e90cd
ios-unit-tests: Started using rsync instead of cp -R to copy frameworks. (#9471)
* Started using rsync instead of cp -R to copy frameworks.

* Removed stray input files for xcode script.
2019-06-25 08:59:19 -07:00
Shi-Hao Hong
f76d664e5c
Test cleanup geometry_test.dart (#9458)
* Refactor and clean up geometry_tests.dart

* Refactor and clean up stub_ui geometry_tests.dart
2019-06-24 21:52:09 -07:00
gaaclarke
b7dd1cdce9
ios-unit-tests: Fixed ocmock system header search paths. (#9469) 2019-06-24 17:04:44 -07:00
gaaclarke
a6e5b10f22
Forgot a usage of a variable in our script. (#9467) 2019-06-24 16:49:19 -07:00
gaaclarke
183a76b38d
Added shebangs to ios unit test scripts. (#9464) 2019-06-24 14:02:38 -07:00
gaaclarke
52ebf4c429
Made sure that the run_tests script returns the right error code. (#9456) 2019-06-24 11:22:41 -07:00
Shi-Hao Hong
297cbd4b15
Convert RRect.scaleRadii to public method (#9452)
* convert RRect.scaleRadii to public method

* Add scaleRadii tests
2019-06-24 11:20:25 -07:00
gaaclarke
f6389583f4
Ios unit tests choose engine (#9432)
* Split out the run_tests script to a build_and_run_tests script to make
it easier to run the tests on luci.

* Made build and run pass in its argument to run.
2019-06-21 16:43:35 -07:00
gaaclarke
cd973f8aae
Added unit tests for the ios code. (#9388)
* Added unit tests for the ios code.

* Moved the tests to live next to the source.

* Added mocking library.

* Fixed formatting and removed third_party from the format check.

* fixed formatting 2

* Removed ocmock from third_party.

* Added ocmock to third_party, compile from source.

* removed ocmock from license checking

* updated licenses_flutter

* updated tool_signature
2019-06-20 17:37:03 -07:00
Chinmay Garde
96a1a843cb
Replace lock_guard with scoped_lock and use class template argument deduction. (#9338) 2019-06-17 10:08:45 -07:00
liyuqian
9f088c65ee
Add onReportTimings and FrameRasterizedCallback API (#8983)
Using it, a Flutter app can monitor missing frames in the release mode, and a custom Flutter runner (e.g., Fuchsia) can add a custom FrameRasterizedCallback.

Related issues:
https://github.com/flutter/flutter/issues/26154
https://github.com/flutter/flutter/issues/31444
https://github.com/flutter/flutter/issues/32447

Need review as soon as possible so we can merge this before the end of May to catch the milestone.

Tests added:
* NoNeedToReportTimingsByDefault
* NeedsReportTimingsIsSetWithCallback
* ReportTimingsIsCalled
* FrameRasterizedCallbackIsCalled
* FrameTimingSetsAndGetsProperly
* onReportTimings preserves callback zone
* FrameTiming.toString has the correct format

This will need a manual engine roll as the TestWindow defined in the framework needs to implement onReportTimings.
2019-06-06 10:42:48 -07:00
Dan Field
79c6ce19a1
Preserve safe area (#8848)
Preserve safe area on Window regardless of insets.
2019-05-31 09:24:38 -07:00
Chinmay Garde
37b367e4d2
Allow specifying both Dart and non-Dart fixtures in engine unit-tests. (#9113)
* 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.
2019-05-28 19:11:47 -07:00
Michael Klimushyn
14c82d9969
Only cache required frames (#8837)
Remove the extra `decodedCacheRatioCap` parameter, and the
`_frameBitmaps` member from `Codec`. This means that small looped images
will consume more CPU but prevents us from hitting OOM exceptions based
on trying to render multiple larger images.

Also switch to fDisposalMethod for caching frames.

Previously we looped over every single SkCodec::FrameInfo, tracked its
`fRequiredFrame`, and then saved any frames matching those indeces.
Doing this instead avoids that initialization loop and extra data
structure.
2019-05-13 11:18:20 -07:00
Kaushik Iska
e7e6689b7f
Expose API to decode images to specified dimensions (#8596)
* Dart side resize primitives exposed

* Write the codec side changes

* return un-scaled image if we can not allocate bitmap

* Format _instantiateImageCodec calls to be single lined

Move null check for size to be inner

* Address CR comments and make image resize dimensions container

* Round not trunc, also format

* Add tests, remove ImageResizeDims from api surface

* Make placeholder value public

* Make the api side changes

* Add a feature to resize pixels and also add tests

* Fix grammar and add more info
2019-05-08 13:57:35 -07:00
Dan Field
2b1f9925e4
new lints (#8849)
Dart lints added:
* Avoid optional new
* Avoid optional const
* Prefer single quotes
* Prefer default assignment `=`
2019-05-07 16:10:21 -07:00
liyuqian
50de4692a5
Check the matrix in pushTransform (#8758)
Fixes flutter/flutter#31650
2019-04-26 14:09:53 -07:00
Todd Volkert
0c9c293b56
Add Rect.fromCenter() constructor (#8716) 2019-04-25 14:40:29 -07:00
Dan Field
3e47b4bb39
Reland const Rect/RRect (#8695) 2019-04-23 11:21:03 -07:00
Dan Field
0523870e0b
Add tests from framework (#8692) 2019-04-22 16:39:00 -07:00
Dan Field
4f2fd84cbc
Revert Rect/RRect 64 bit (#8690)
* Revert "fix toString (#8688)"

This reverts commit 9fa7336784b56ef70fd3580ac54d2939d1faa5a0.

* Revert "Make Rect and RRect use 64 bit doubles, and make them const-able (#8565)"

This reverts commit c12315273f6344175dae748ec1f23e15b4e7d59e.
2019-04-22 15:45:59 -07:00
Dan Field
9fa7336784
fix toString (#8688) 2019-04-22 14:12:31 -07:00
Dan Field
c12315273f
Make Rect and RRect use 64 bit doubles, and make them const-able (#8565)
* Make Rect and RRect 64bit and const-able
2019-04-22 12:58:48 -07:00
Chinmay Garde
2e4f0a4a72
Put the testing lib in the flutter namespace. (#8661) 2019-04-20 20:42:46 -07:00