Skip to content

Conversation

@clocksmith
Copy link
Contributor

@clocksmith clocksmith commented Mar 10, 2022

Description

Tests

  • Added platform tests for using the correct splashFactory when useMaterial3 is false
  • Added platform tests for using the correct splashFactory when useMaterial3 is true
  • Existing ThemeData global test continues to pass.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

@clocksmith clocksmith added f: material design flutter/packages/flutter/material repository. work in progress; do not review labels Mar 10, 2022
@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Mar 10, 2022
@clocksmith clocksmith changed the title restrict InkSparkle to Android non-web and material 3 [Material] Use InkSparkle for Android non-web when useMaterial3 is set to true in ThemeData Mar 10, 2022
@clocksmith
Copy link
Contributor Author

not sure why one of the tests is failing, the case where it should be InkSparkle...

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: <Instance of '_InkSparkleFactory'>
  Actual: <Instance of '_InkSplashFactory'>

When the exception was thrown, this was the stack:
#4      main.<anonymous closure> (file:///Users/xxxxxx/git/flutter/packages/flutter/test/material/theme_data_test.dart:279:9)
#5      main.<anonymous closure> (file:///Users/xxxxxx/git/flutter/packages/flutter/test/material/theme_data_test.dart:271:97)
#6      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:170:29)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

This was caught by the test expectation on the following line:
  file:///Users/xxxxxx/git/flutter/packages/flutter/test/material/theme_data_test.dart line 279
The test description was:
  splashFactory is InkSparkle only for Android non-web when useMaterial3 is true (variant:
  TargetPlatform.android)
════════════════════════════════════════════════════════════════════════════════════════════════════
00:03 +21 -1: splashFactory is InkSparkle only for Android non-web when useMaterial3 is true (variant: TargetPlatform.android) [E]                                                                                                                       
  Test failed. See exception logs above.
  The test description was: splashFactory is InkSparkle only for Android non-web when useMaterial3 is true (variant: TargetPlatform.android)
  
00:03 +53 -1: Some tests failed.

Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for doing this. Looks good, just a couple of suggestions below.

@darrenaustin
Copy link
Contributor

darrenaustin commented Mar 10, 2022

not sure why one of the tests is failing, the case where it should be InkSparkle...

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: <Instance of '_InkSparkleFactory'>
  Actual: <Instance of '_InkSplashFactory'>

As I mentioned in the review, this is due to useMaterial3 only changing the default splash factory if it is set in the constructor, and not in copyWith.

@LasseRosenow
Copy link
Contributor

I'm curious: is the sparkle effect not part of material design, or why is it only applied on Android?

@clocksmith
Copy link
Contributor Author

Understood about the useMaterial3 flag and how it only responds to constructor, and not copy with. I modified the paragraphs that explain this, and added a list structure to add new properties that are affected by flag

@clocksmith
Copy link
Contributor Author

clocksmith commented Mar 10, 2022

I'm curious: is the sparkle effect not part of material design, or why is it only applied on Android?

The current goal is to make a ripple in Flutter that is consistent with Android 12. I will try to find out a better answer for your question though.

@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

@clocksmith
Copy link
Contributor Author

clocksmith commented Mar 12, 2022

I think some tests are failing due to tickers not being stopped when the widget containing a FragmentProgram is disposed. Other tests pass probably because the shader compilation finishes so quickly, but some tests do not give it time.

Is there currently a way to stop/cancel the async shader compilation once started? @zanderso @chinmaygarde @flar is there something that can be done with the FragmentProgram in onDispose here, or should the affected tests be fixed with something like pumpAndSettle or waiting till the compilation is done?

Test exception:

02:06 +3129 ~1: /b/s/w/ir/x/w/flutter/packages/flutter/test/material/navigation_rail_test.dart: onDestinationSelected is not called if null                                                            
Pending timers:
Timer (duration: 0:00:00.000000, periodic: false), created:
#0      new FakeTimer._ (package:fake_async/fake_async.dart:284:41)
#1      FakeAsync._createTimer (package:fake_async/fake_async.dart:248:27)
#2      FakeAsync.run.<anonymous closure> (package:fake_async/fake_async.dart:181:19)
#7      FragmentProgram.compile (dart:ui/painting.dart:3778:12)
#8      FragmentShaderManager.compile (package:flutter/src/material/ink_sparkle.dart:620:41)
#9      FragmentShaderManager.inkSparkle (package:flutter/src/material/ink_sparkle.dart:614:19)
#10     _InkSparkleFactory.compileShaderIfNeccessary (package:flutter/src/material/ink_sparkle.dart:427:29)
#11     new InkSparkle (package:flutter/src/material/ink_sparkle.dart:125:24)
#12     _InkSparkleFactory.create (package:flutter/src/material/ink_sparkle.dart:452:12)
#13     _InkResponseState._createInkFeature (package:flutter/src/material/ink_well.dart:912:72)
#14     _InkResponseState._startSplash (package:flutter/src/material/ink_well.dart:990:42)
#15     _InkResponseState._handleTapDown (package:flutter/src/material/ink_well.dart:971:5)
#16     TapGestureRecognizer.handleTapDown.<anonymous closure> (package:flutter/src/gestures/tap.dart:586:61)
#17     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:198:24)
#18     TapGestureRecognizer.handleTapDown (package:flutter/src/gestures/tap.dart:586:11)
#19     BaseTapGestureRecognizer._checkDown (package:flutter/src/gestures/tap.dart:289:5)
#20     BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:267:7)
#21     GestureArenaManager._resolveByDefault (package:flutter/src/gestures/arena.dart:251:25)
#22     GestureArenaManager._tryToResolveArena.<anonymous closure> (package:flutter/src/gestures/arena.dart:232:31)
#29     FakeAsync.flushMicrotasks (package:fake_async/fake_async.dart:193:32)
#30     AutomatedTestWidgetsFlutterBinding.runTest.<anonymous closure> (package:flutter_test/src/binding.dart:1256:17)
#31     AutomatedTestWidgetsFlutterBinding.runTest.<anonymous closure> (package:flutter_test/src/binding.dart:1243:35)
(elided 25 frames from dart:async and package:stack_trace)

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown running a test:
A Timer is still pending even after the widget tree was disposed.
'package:flutter_test/src/binding.dart':
Failed assertion: line 1291 pos 12: '!timersPending'

When the exception was thrown, this was the stack:
#2      AutomatedTestWidgetsFlutterBinding._verifyInvariants (package:flutter_test/src/binding.dart:1291:12)
#3      TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:848:7)
<asynchronous suspension>
(elided 2 frames from class _AssertionError)

The test description was:
  onDestinationSelected is not called if null
════════════════════════════════════════════════════════════════════════════════════════════════════

@chinmaygarde
Copy link
Member

Is there currently a way to stop/cancel the async shader compilation once started? ... is there something that can be done with the FragmentProgram in onDispose here...

While shader compilation may be async, it isn't concurrent. And there is no way to stop a compilation once it has started on the UI thread. If shader compilation takes too long, the task to service the onDispose call will be queued behind the completion of shader compilation (as will any other tasks on the UI thread).

@clocksmith clocksmith changed the title [Material] Use InkSparkle for Android non-web when useMaterial3 is set to true in ThemeData [Material] Use InkSparkle for splashFactory in ThemeData when useMaterial3 is true for Android non-web runtimes Mar 15, 2022
@clocksmith clocksmith merged commit 7c73053 into flutter:master Mar 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Mar 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Mar 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ThemeData should use InkSparkle for splashFactory when useMaterial3 is true

6 participants