You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Caching callbacks in RenderSemanticsGestureHandler doesn't work as expected #11552
RenderSemanticsGestureHandler contains multiple setters in the following style:
setonTap(GestureTapCallback value) {
if (_onTap == value)
return;
_onTap = value;
// Do work because value as changed.
}
In real words: if the setter is set to the same value it already has no extra work should happen. However, in the precise environment the setters are called this check doesn't work as expected.
The setters are called from _GestureSemantics and the callbacks are set to a member function of that class. While RenderSemanticsGestureHandler is a long-lived object, _GestureSemantics is a short-lived widget. In fact, in every frame, a new _GestureSemantics is build and the callbacks of RenderSemanticsGestureHandler are updated to the new _GestureSemantics's member functions. The member function from the old _GestureSemantics object and the one from the new _GestureSemantics object are not considered equal by Dart, the _onTap == value check in the setter returns false and we do extra work in the setter for nothing as the actual onTap handler might not have changed.
Actually, there are additional checks in the setter to ensure that we don't do anything crazy expansive in these cases. With that, the issue doesn't seem to be a (performance) concern. It was just slightly confusing when debugging this. I am going to close this for now.
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 flutter doctor -v and a minimal reproduction of the issue.
Activity
goderbauer commentedon Aug 8, 2017
Actually, there are additional checks in the setter to ensure that we don't do anything crazy expansive in these cases. With that, the issue doesn't seem to be a (performance) concern. It was just slightly confusing when debugging this. I am going to close this for now.
Make tear-offs cacheable for RenderSemanticsGestureHandler (#11556)
github-actions commentedon Sep 4, 2021
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
flutter doctor -vand a minimal reproduction of the issue.