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
Unexpected null value in BaseTapGestureRecognizer._checkDown #82107
Comments
@jhass
|
as I outlined my app is essentially a ListView of user generated content, in particular markdown transformed to HTML and rendered using the flutter_html. Given this app is also a hobby project I cannot foresee being able to invest the substantial time it will take to find such a minimal reproducing example. Please don't make this a requirement to you fixing crashes in your product. Do you imagine the fix is substantially different to turning the null assertion into a null check? |
It looks like you are describing a bug in a third party package, flutter_html is not supported by Flutter team |
Did you take a look at the stack trace? Where does it as much as touch third party code? |
It seems to be quite the race condition, I couldn't find reliable reproduction steps even on the known bad version :/ Do you see any negative consequences from turning that null assertion into a null check? The other solution I see, if that instance variable is modified concurrently, is passing the value down the call chain as a parameter from the place it was last null checked. |
Sorry, I'm not quite sure I understood what you are asking. This line of the stack trace you attached indicates that exception is thrown from
As far as I can tell, this assertion is there to ensure that gesture recognizer is properly used. Converting it into null check will hide potential errors like this and developers will be left unaware of potential unexpected behaviors |
Let's dive into the code,
I'm sorry if there's a better term for the flutter/packages/flutter/lib/src/gestures/tap.dart Lines 283 to 289 in b7dd9ac
It's using |
cc @dkwingsmt |
I reproduced it Code sampleimport 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Home(),
);
}
}
class Home extends StatelessWidget {
Home({Key key}) : super(key: key);
final list = List.generate(1000, (index) => index);
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView.builder(
itemCount: list.length,
itemBuilder: (BuildContext context, int index) {
return RawGestureDetector(
gestures: {
MultipleTapGestureRecognizer: GestureRecognizerFactoryWithHandlers<MultipleTapGestureRecognizer>(
() => MultipleTapGestureRecognizer(),
(MultipleTapGestureRecognizer instance) => instance
..onTap = () {
print('tap');
},
)
},
child: const Image(
image: NetworkImage('https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg'),
),
);
},
),
);
}
}
class MultipleTapGestureRecognizer extends TapGestureRecognizer {
@override
void rejectGesture(int pointer) {
acceptGesture(pointer);
}
} flutter doctor -v
When assertions disabled, it throws the error from the OP
|
That's great, thank you! |
I see the same behavior as below: console error log
flutter doctor -v
|
Same issue #71331 |
Looks like the initial approach is from https://gist.github.com/Nash0x7E2/08acca529096d93f3df0f60f9c034056 This was introduced to flutter_html to fix another issue: Sub6Resources/flutter_html#631 Your "fix" in flutter_carousel_slider was just removing the workaround, restoring the original issue this wanted to fix. Nobody ever followed up with a proper way to do this: https://github.com/serenader2014/flutter_carousel_slider/blob/master/lib/carousel_slider.dart#L338 What is the proper way to do this? I hope just living with the broken behavior this wants to workaround is not your recommended solution. |
As @xu-baolin points out, this code is just not legal: class MultipleTapGestureRecognizer extends TapGestureRecognizer {
@override
void rejectGesture(int pointer) {
acceptGesture(pointer);
}
} Since the |
Please file this bug to the package owner. (Or not, if you don't mean to file at all.) We perform assertions against internal states all the time, especially for complex logic as gesture recognizers, and we encourage so. We have done too few assertions, not too many. Assertions ensure that premises are kept throughout the lifecycle of the object. In the situation of this ticket, |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
I'm seeing the following crash in a Flutter 2.0.6 based app:
I couldn't find a matching existing report, but it seems quite close to #43310 / #50574.
Unfortunately I have no good way to reproduce this but I'm seeing it while scrolling down a
ListView
of user generated content containing among lots of other things tapable images. So maybe it's related to a large tapable area being used to scroll down something it's contained within.The text was updated successfully, but these errors were encountered: