这是indexloc提供的服务,不要输入任何密码
Skip to content

fix resampling leads to Hard to tap #81022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 28, 2021

Conversation

LinXiaoTao
Copy link
Contributor

@LinXiaoTao LinXiaoTao commented Apr 23, 2021

On Flutter 2.0, enabling resampling will result in hard to tap on Android devices.

fixes #73286

I think it was caused by this commit #67080.
When converting PointerUpEvent to PointerMoveEvent(see code 1), buttons are 0(see code 2), so the stopTrackingPointer method is executed(see code 3) and the tap callback is cancelled.

// src/gestures/resampler.dart
if (event is! PointerMoveEvent && event is! PointerHoverEvent) {                                    
  // Add synthetics `move` or `hover` event if position has changed.                                
  // Note: Devices without `hover` events are expected to always have                               
  // `add` and `down` events with the same position and this logic will                             
  // therefor never produce `hover` events.                                                         
  if (position != _position) {                                                                      
    final Offset delta = position - _position; 
    // code 1                                                     
    callback(_toMoveOrHoverEvent(event, position, delta, _pointerIdentifier, sampleTime, wasDown)); 
    _position = position;                                                                           
  }                                                                                                 
  callback(event.copyWith(                                                                          
    position: position,                                                                             
    delta: Offset.zero,                                                                             
    pointer: pointerIdentifier,                                                                     
    timeStamp: sampleTime,                                                                          
  ));                                                                                               
} 

PointerEvent _toMoveEvent(                     
  PointerEvent event,                          
  Offset position,                             
  Offset delta,                                
  int pointerIdentifier,                       
  Duration timeStamp,                          
) { 
  // code 2                                           
  return PointerMoveEvent(                     
    timeStamp: timeStamp,                      
    pointer: pointerIdentifier,                
    kind: event.kind,                          
    device: event.device,                      
    position: position,                        
    delta: delta,                              
    buttons: event.buttons,                    
    obscured: event.obscured,                  
    pressure: event.pressure,                  
    pressureMin: event.pressureMin,            
    pressureMax: event.pressureMax,            
    distanceMax: event.distanceMax,            
    size: event.size,                          
    radiusMajor: event.radiusMajor,            
    radiusMinor: event.radiusMinor,            
    radiusMin: event.radiusMin,                
    radiusMax: event.radiusMax,                
    orientation: event.orientation,            
    tilt: event.tilt,                          
    platformData: event.platformData,          
    synthesized: event.synthesized,            
    embedderId: event.embedderId,              
  );                                           
}                                                                                                                                                
// src/gestures/tap.dart
@override                                                
void handlePrimaryPointer(PointerEvent event) {          
  if (event is PointerUpEvent) {                         
    _up = event;                                         
    _checkUp();                                          
  } else if (event is PointerCancelEvent) {              
    resolve(GestureDisposition.rejected);                
    if (_sentTapDown) {                                  
      _checkCancel(event, '');                           
    }                                                    
    _reset();                                            
  } else if (event.buttons != _down!.buttons) {          
    resolve(GestureDisposition.rejected); 
    // code 3          
    stopTrackingPointer(primaryPointer!);                
  }                                                      
}  

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Apr 23, 2021
@google-cla
Copy link

google-cla bot commented Apr 23, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@google-cla google-cla bot added the cla: no label Apr 23, 2021
@LinXiaoTao
Copy link
Contributor Author

@googlebot I signed it!

@google-cla
Copy link

google-cla bot commented Apr 23, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: yes and removed cla: no labels Apr 23, 2021
@LinXiaoTao
Copy link
Contributor Author

@googlebot I signed it!

@xu-baolin
Copy link
Member

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@LinXiaoTao Hi, This needs a test.

@LinXiaoTao
Copy link
Contributor Author

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.
If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?
Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@LinXiaoTao Hi, This needs a test.

Hi,Does it mean writing test cases?

@xu-baolin
Copy link
Member

Yes.

@LinXiaoTao
Copy link
Contributor Author

@xu-baolin Hi,Can you help me review the code again.

@LinXiaoTao
Copy link
Contributor Author

@dreveman Hi,Can you help me review the code.

Copy link
Contributor

@dreveman dreveman left a comment

Choose a reason for hiding this comment

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

Good catch!

@LinXiaoTao LinXiaoTao requested a review from dreveman April 26, 2021 02:35
Copy link
Contributor

@dreveman dreveman left a comment

Choose a reason for hiding this comment

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

thanks! looks good after making suggested changes

Co-authored-by: David Reveman <david@reveman.com>
@google-cla
Copy link

google-cla bot commented Apr 27, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot removed the cla: yes label Apr 27, 2021
Co-authored-by: David Reveman <david@reveman.com>
@google-cla google-cla bot added the cla: no label Apr 27, 2021
@google-cla
Copy link

google-cla bot commented Apr 27, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

Co-authored-by: David Reveman <david@reveman.com>
@google-cla
Copy link

google-cla bot commented Apr 27, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

Co-authored-by: David Reveman <david@reveman.com>
@google-cla
Copy link

google-cla bot commented Apr 27, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

Co-authored-by: David Reveman <david@reveman.com>
@google-cla
Copy link

google-cla bot commented Apr 27, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

Co-authored-by: David Reveman <david@reveman.com>
@google-cla
Copy link

google-cla bot commented Apr 27, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@dreveman
Copy link
Contributor

Please go ahead and merge this after signing the cla.

@LinXiaoTao
Copy link
Contributor Author

LinXiaoTao commented Apr 28, 2021

Please go ahead and merge this after signing the cla.

Hi, I have signed cla. Could it be because of your email address in the commit?

@LinXiaoTao
Copy link
Contributor Author

@googlebot I fixed it.

@google-cla
Copy link

google-cla bot commented Apr 28, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@dreveman dreveman merged commit 8ddfc80 into flutter:master Apr 28, 2021
@dreveman
Copy link
Contributor

Yes, my alternative email was causing problems. I merged this for you. Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hard to tap when resampling enabled on Samsung Galaxy S20 Ultra
3 participants