Repository: flutter
Issue: Proposal to add more information to help analyze hitTest exception
Labels: framework,a: quality,f: gestures,a: debugging,c: proposal,a: error message,a: null-safety,P3,team-framework,triaged-framework

## Proposal
There is too little on-site information about hitTest crash, so it is difficult to find out what scenario caused the problem. 
**Can we add more information to help analyze the problem?**

A hitTest exception stack trace from online monitor like this, we can find that all is framework stack, and it is difficult to troubleshoot where is the business code going wrong.

```dart
Null check operator used on a null value
#0      RenderBox.hitTest (package:flutter/src/rendering/box.dart:2423)
#1      _RenderTheatre.hitTestChildren.<anonymous closure> (package:flutter/src/widgets/overlay.dart:765)
#2      BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787)
#3      RenderBoxContainerDefaultsMixin.defaultHitTestChildren (package:flutter/src/rendering/box.dart:2780)
#4      RenderStack.hitTestChildren (package:flutter/src/rendering/stack.dart:675)
#5      RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#6      RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#7      RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#8      RenderRotatedBox.hitTestChildren.<anonymous closure> (package:flutter/src/rendering/rotated_box.dart:108)
#9      BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787)
#10     RenderShiftedBox.hitTestChildren (package:flutter/src/rendering/shifted_box.dart:80)
#11     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#12     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#13     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#14     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#15     RenderProxyBoxWithHitTestBehavior.hitTest (package:flutter/src/rendering/proxy_box.dart:180)
#16     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#17     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#18     _RenderTheatre.hitTestChildren.<anonymous closure> (package:flutter/src/widgets/overlay.dart:765)
#19     BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787)
#20     RenderBoxContainerDefaultsMixin.defaultHitTestChildren (package:flutter/src/rendering/box.dart:2780)
#21     RenderFlex.hitTestChildren (package:flutter/src/rendering/flex.dart:1132)
#22     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#23     RenderRotatedBox.hitTestChildren.<anonymous closure> (package:flutter/src/rendering/rotated_box.dart:108)
#24     BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787)
#25     RenderShiftedBox.hitTestChildren (package:flutter/src/rendering/shifted_box.dart:80)
#26     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#27     RenderRotatedBox.hitTestChildren.<anonymous closure> (package:flutter/src/rendering/rotated_box.dart:108)
#28     BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787)
#29     _RenderSingleChildViewport.hitTestChildren (package:flutter/src/widgets/single_child_scroll_view.dart:627)
#30     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#31     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#32     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#33     RenderOffstage.hitTest (package:flutter/src/rendering/proxy_box.dart:3372)
#34     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#35     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#36     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#37     RenderProxyBoxWithHitTestBehavior.hitTest (package:flutter/src/rendering/proxy_box.dart:180)
#38     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#39     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#40     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#41     RenderProxyBoxWithHitTestBehavior.hitTest (package:flutter/src/rendering/proxy_box.dart:180)
#42     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#43     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#44     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#45     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#46     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#47     RenderCustomPaint.hitTestChildren (package:flutter/src/rendering/custom_paint.dart:536)
#48     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#49     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#50     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#51     RenderRotatedBox.hitTestChildren.<anonymous closure> (package:flutter/src/rendering/rotated_box.dart:108)
#52     BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787)
#53     RenderShiftedBox.hitTestChildren (package:flutter/src/rendering/shifted_box.dart:80)
#54     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#55     _RenderTheatre.hitTestChildren.<anonymous closure> (package:flutter/src/widgets/overlay.dart:765)
#56     BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787)
#57     RenderBoxContainerDefaultsMixin.defaultHitTestChildren (package:flutter/src/rendering/box.dart:2780)
#58     RenderStack.hitTestChildren (package:flutter/src/rendering/stack.dart:675)
#59     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#60     _RenderTheatre.hitTestChildren.<anonymous closure> (package:flutter/src/widgets/overlay.dart:765)
#61     BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787)
#62     RenderBoxContainerDefaultsMixin.defaultHitTestChildren (package:flutter/src/rendering/box.dart:2780)
#63     RenderFlex.hitTestChildren (package:flutter/src/rendering/flex.dart:1132)
#64     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#65     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#66     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#67     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#68     RenderProxyBoxWithHitTestBehavior.hitTest (package:flutter/src/rendering/proxy_box.dart:180)
#69     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#70     RenderProxyBoxWithHitTestBehavior.hitTest (package:flutter/src/rendering/proxy_box.dart:180)
#71     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#72     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#73     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#74     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#75     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#76     RenderCustomPaint.hitTestChildren (package:flutter/src/rendering/custom_paint.dart:536)
#77     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#78     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#79     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#80     RenderClipPath.hitTest (package:flutter/src/rendering/proxy_box.dart:1690)
#81     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#82     RenderProxyBoxWithHitTestBehavior.hitTest (package:flutter/src/rendering/proxy_box.dart:180)
#83     RenderRotatedBox.hitTestChildren.<anonymous closure> (package:flutter/src/rendering/rotated_box.dart:108)
#84     BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787)
#85     RenderShiftedBox.hitTestChildren (package:flutter/src/rendering/shifted_box.dart:80)
#86     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#87     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#88     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#89     RenderClipRect.hitTest (package:flutter/src/rendering/proxy_box.dart:1451)
#90     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#91     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#92     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#93     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#94     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#95     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#96     RenderOffstage.hitTest (package:flutter/src/rendering/proxy_box.dart:3372)
#97     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#98     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#99     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#100    RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#101    RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#102    RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#103    RenderOffstage.hitTest (package:flutter/src/rendering/proxy_box.dart:3372)
#104    RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#105    RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#106    _RenderTheatre.hitTestChildren.<anonymous closure> (package:flutter/src/widgets/overlay.dart:765)
#107    BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787)
#108    _RenderTheatre.hitTestChildren (package:flutter/src/widgets/overlay.dart:760)
#109    RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#110    RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#111    RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#112    RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#113    RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#114    RenderAbsorbPointer.hitTest (package:flutter/src/rendering/proxy_box.dart:3470)
#115    RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#116    RenderProxyBoxWithHitTestBehavior.hitTest (package:flutter/src/rendering/proxy_box.dart:180)
#117    RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#118    RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#119    RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#120    RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#121    RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#122    RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#123    RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:133)
#124    RenderBox.hitTest (package:flutter/src/rendering/box.dart:2424)
#125    RenderView.hitTest (package:flutter/src/rendering/view.dart:187)
#126    RendererBinding.hitTest (package:flutter/src/rendering/binding.dart:521)
#127    GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:288)
#128    GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:280)
#129    GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:238)
#130    GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:221)
#131    _rootRunUnary (dart:async/zone.dart:1370)
#132    _CustomZone.runUnary (dart:async/zone.dart:1265)
#133    _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170)
#134    _invoke1 (dart:ui/hooks.dart:236)
#135    PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:276)
#136    _dispatchPointerDataPacket (dart:ui/hooks.dart:99)
```


Similarly, when a build exception occurs, the debugCreator is collected to help analyze which widget is causing the exception.
```
        try {
          _dirtyElements[index].rebuild();
        } catch (e, stack) {
          _debugReportException(
            ErrorDescription('while rebuilding dirty elements'),
            e,
            stack,
            informationCollector: () sync* {
              if (index < _dirtyElements.length) {
                yield DiagnosticsDebugCreator(DebugCreator(_dirtyElements[index]));
                yield _dirtyElements[index].describeElement('The element being rebuilt at the time was index $index of $dirtyCount');
              } else {
                yield ErrorHint('The element being rebuilt at the time was index $index of $dirtyCount, but _dirtyElements only had ${_dirtyElements.length} entries. This suggests some confusion in the framework internals.');
              }
            },
          );
        }
```
We modified the code here so that exceptions on release mode can also include debugCreator information with minimal performance impact.