Apple Pencil Initial Pressure Incorrectly Reported as 0.33 on First Contact in Flutter
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Summary:
When using Listener to track Apple Pencil input on an iPad Pro (M1), the first PointerDownEvent always reports a pressure of 0.33, regardless of actual pressure applied. The second event often has a predicted position rather than the real touch data. This issue causes drawing applications to start strokes with an incorrect, fixed pressure value, leading to unintended thick or thin strokes at the start of a line.
This behavior is likely due to Flutter using the estimated initial touch properties from iOS but failing to update the PointerEvent.pressure when iOS provides the corrected pressure values. This is a well known hardware quirk of the apple pencil.
### Steps to reproduce
To reproduce, simply use the code below and view debug logs while using an iPad pro and apple pencil 2 (this likely occurs across iPad and Apple Pencil configurations)
### Expected results
Expected Behavior:
• The first PointerDownEvent should have an accurate pressure value, reflecting the actual force applied.
• If iOS initially estimates a placeholder value (like 0.33), Flutter should update the event when iOS provides the real data.
• The second event should not be predicted, but rather reflect the actual pen movement.
### Actual results
Actual Behavior:
• The first PointerDownEvent and first PointerMoveEvent always reports a fixed pressure of 0.33, no matter how hard the Apple Pencil is pressed. (first two samples have this value)
• The second event sometimes provides an incorrect predicted position instead of real data.
• The pressure only starts behaving correctly after the first few samples, but by then, an incorrect stroke has already been drawn.
### Code sample
Code sample
```dart
Listener(
onPointerDown: (event) {
if (event.kind == PointerDeviceKind.stylus || event.kind == PointerDeviceKind.invertedStylus) {
debugPrint('PointerDown - Pressure: ${event.pressure}, Position: ${event.localPosition}');
}
},
onPointerMove: (event) {
if (event.kind == PointerDeviceKind.stylus || event.kind == PointerDeviceKind.invertedStylus) {
debugPrint('PointerMove - Pressure: ${event.pressure}, Position: ${event.localPosition}');
}
},
child: Container(color: Colors.white, width: double.infinity, height: double.infinity),
);
```
### Screenshots or Video
Screenshots / Video demonstration
https://github.com/user-attachments/assets/c2ae74f0-cce0-4ce6-8cc0-644f8c8edba7
### Logs
Logs
```console
flutter: onPointerDown: 0.3333333333333333
flutter: onPointerMove: 0.3333333333333333
flutter: onPointerMove: 0.1887304941813151
```
### Flutter Doctor output
Doctor output
```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.0, on macOS 14.3 23D56 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 15.3)
! CocoaPods 1.15.2 out of date (1.16.2 is recommended).
CocoaPods is a package manager for iOS or macOS platform code.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/to/platform-plugins
To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.97.2)
[✓] Connected device (4 available)
```
### Additional Notes:
• This issue is present in other frameworks (Unity, UIKit) if Apple Pencil updates are not handled correctly.
• Apple’s touchesEstimatedPropertiesUpdated method provides a correction event, which Flutter may not be using.
• A workaround is to ignore the first event’s pressure or interpolate the first few samples to smooth out the incorrect value.
### Possible Fixes:
• Flutter should listen for touchesEstimatedPropertiesUpdated from iOS and update the pressure value accordingly.
• Alternatively, Flutter could delay the first sample until a corrected pressure value is available.
Contributor guide
Assessment
This issue has not been assessed yet.