calcitem / Sanmill

Sanmill is an open-source, UCI-like Mill/Morris/Merrills/Mühle/Malom (and its variants) program with CUI, Flutter GUI and Qt GUI, sharing and freely distributing the code, tools and data needed to deliver this mill game. We do this because we are convinced that open software and open data are key ingredients to make rapid progress.
https://play.google.com/store/apps/details?id=com.calcitem.sanmill
GNU General Public License v3.0
145 stars 21 forks source link

[Error] BoxConstraints has a negative minimum width. #432

Closed calcitem closed 2 years ago

calcitem commented 2 years ago

Commit 7794889b974b5acdb6fffd05d026755ae90c9c4a

Except when launching app. (Debug)

BoxConstraints.debugAssertIsValid.<anonymous closure>.throwError (box.dart:515)
BoxConstraints.debugAssertIsValid.<anonymous closure> (box.dart:544)
BoxConstraints.debugAssertIsValid (box.dart:563)
new ConstrainedBox (basic.dart:2347)
Container.build (container.dart:428)
StatelessElement.build (framework.dart:4662)
ComponentElement.performRebuild (framework.dart:4588)
Element.rebuild (framework.dart:4311)
ComponentElement._firstBuild (framework.dart:4566)
ComponentElement.mount (framework.dart:4561)
Element.inflateWidget (framework.dart:3631)
Element.updateChild (framework.dart:3383)
SingleChildRenderObjectElement.mount (framework.dart:6123)
Element.inflateWidget (framework.dart:3631)
Element.updateChild (framework.dart:3383)
ComponentElement.performRebuild (framework.dart:4613)
StatefulElement.performRebuild (framework.dart:4763)
Element.rebuild (framework.dart:4311)
ComponentElement._firstBuild (framework.dart:4566)
StatefulElement._firstBuild (framework.dart:4754)
ComponentElement.mount (framework.dart:4561)
Element.inflateWidget (framework.dart:3631)
MultiChildRenderObjectElement.inflateWidget (framework.dart:6261)
MultiChildRenderObjectElement.mount (framework.dart:6272)
Element.inflateWidget (framework.dart:3631)
Element.updateChild (framework.dart:3383)
SingleChildRenderObjectElement.mount (framework.dart:6123)
Element.inflateWidget (framework.dart:3631)
Element.updateChild (framework.dart:3383)
SingleChildRenderObjectElement.mount (framework.dart:6123)
Element.inflateWidget (framework.dart:3631)
Element.updateChild (framework.dart:3383)
SingleChildRenderObjectElement.mount (framework.dart:6123)
Element.inflateWidget (framework.dart:3631)
Element.updateChild (framework.dart:3383)
ComponentElement.performRebuild (framework.dart:4613)
Element.rebuild (framework.dart:4311)
ComponentElement._firstBuild (framework.dart:4566)
ComponentElement.mount (framework.dart:4561)
Element.inflateWidget (framework.dart:3631)
Element.updateChild (framework.dart:3383)
ComponentElement.performRebuild (framework.dart:4613)
Element.rebuild (framework.dart:4311)
ComponentElement._firstBuild (framework.dart:4566)
ComponentElement.mount (framework.dart:4561)
Element.inflateWidget (framework.dart:3631)
Element.updateChild (framework.dart:3383)
ComponentElement.performRebuild (framework.dart:4613)
StatefulElement.performRebuild (framework.dart:4763)
Element.rebuild (framework.dart:4311)
ComponentElement._firstBuild (framework.dart:4566)
StatefulElement._firstBuild (framework.dart:4754)
ComponentElement.mount (framework.dart:4561)
Element.inflateWidget (framework.dart:3631)
Element.updateChild (framework.dart:3383)
ComponentElement.performRebuild (framework.dart:4613)
Element.rebuild (framework.dart:4311)
ComponentElement._firstBuild (framework.dart:4566)
ComponentElement.mount (framework.dart:4561)
Element.inflateWidget (framework.dart:3631)
Element.updateChild (framework.dart:3383)
SliverMultiBoxAdaptorElement.updateChild (sliver.dart:1243)
SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (sliver.dart:1228)
BuildOwner.buildScope (framework.dart:2531)
SliverMultiBoxAdaptorElement.createChild (sliver.dart:1221)
RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (sliver_multi_box_adaptor.dart:349)
RenderObject.invokeLayoutCallback.<anonymous closure> (object.dart:1962)
PipelineOwner._enableMutationsToDirtySubtrees (object.dart:910)
RenderObject.invokeLayoutCallback (object.dart:1962)
RenderSliverMultiBoxAdaptor._createOrObtainChild (sliver_multi_box_adaptor.dart:338)
RenderSliverMultiBoxAdaptor.addInitialChild (sliver_multi_box_adaptor.dart:422)
RenderSliverList.performLayout (sliver_list.dart:79)
RenderObject.layout (object.dart:1852)
RenderSliverEdgeInsetsPadding.performLayout (sliver_padding.dart:137)
RenderSliverPadding.performLayout (sliver_padding.dart:371)
RenderObject.layout (object.dart:1852)
RenderViewportBase.layoutChildSequence (viewport.dart:510)
RenderShrinkWrappingViewport._attemptLayout (viewport.dart:1935)
RenderShrinkWrappingViewport.performLayout (viewport.dart:1881)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderCustomPaint.performLayout (custom_paint.dart:545)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
ChildLayoutHelper.layoutChild (layout_helper.dart:56)
RenderFlex._computeSizes (flex.dart:829)
RenderFlex.performLayout (flex.dart:931)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
_RenderCustomClip.performLayout (proxy_box.dart:1376)
RenderObject.layout (object.dart:1852)
RenderFractionallySizedOverflowBox.performLayout (shifted_box.dart:1165)
RenderObject.layout (object.dart:1852)
RenderPositionedBox.performLayout (shifted_box.dart:437)
RenderObject.layout (object.dart:1852)
ChildLayoutHelper.layoutChild (layout_helper.dart:56)
RenderStack._computeSize (stack.dart:570)
RenderStack.performLayout (stack.dart:597)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
MultiChildLayoutDelegate.layoutChild (custom_layout.dart:171)
_ScaffoldLayout.performLayout (scaffold.dart:1005)
MultiChildLayoutDelegate._callPerformLayout (custom_layout.dart:240)
RenderCustomMultiChildLayoutBox.performLayout (custom_layout.dart:403)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
_RenderCustomClip.performLayout (proxy_box.dart:1376)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderOffstage.performLayout (proxy_box.dart:3428)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
_RenderTheatre.performLayout (overlay.dart:751)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
ChildLayoutHelper.layoutChild (layout_helper.dart:56)
RenderStack._computeSize (stack.dart:570)
RenderStack.performLayout (stack.dart:597)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
_RenderCustomClip.performLayout (proxy_box.dart:1376)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderPositionedBox.performLayout (shifted_box.dart:437)
RenderObject.layout (object.dart:1852)
ChildLayoutHelper.layoutChild (layout_helper.dart:56)
RenderStack._computeSize (stack.dart:570)
RenderStack.performLayout (stack.dart:597)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderProxyBoxMixin.performLayout (proxy_box.dart:116)
RenderObject.layout (object.dart:1852)
RenderView.performLayout (view.dart:165)
RenderObject._layoutWithoutResize (object.dart:1707)
PipelineOwner.flushLayout (object.dart:879)
RendererBinding.drawFrame (binding.dart:497)
WidgetsBinding.drawFrame (binding.dart:883)
RendererBinding._handlePersistentFrameCallback (binding.dart:363)
SchedulerBinding._invokeFrameCallback (binding.dart:1145)
SchedulerBinding.handleDrawFrame (binding.dart:1082)
SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (binding.dart:863)
_rootRun (zone.dart:1420)
_CustomZone.run (zone.dart:1328)
_CustomZone.runGuarded (zone.dart:1236)
_CustomZone.bindCallbackGuarded.<anonymous closure> (zone.dart:1276)
_rootRun (zone.dart:1428)
_CustomZone.run (zone.dart:1328)
_CustomZone.bindCallback.<anonymous closure> (zone.dart:1260)
Timer._createTimer.<anonymous closure> (timer_patch.dart:18)
_Timer._runTimers (timer_impl.dart:395)
_Timer._handleMessage (timer_impl.dart:426)
_RawReceivePortImpl._handleMessage (isolate_patch.dart:192)
Leptopoda commented 2 years ago

Yeah it sometimes happens on the first build and I'm aware of the issue and the cause of it...

I introduced this bug

Leptopoda commented 2 years ago

FYI the problem has to do with screenPaddingH. Its computation can sometimes be negative (if the layout isn't complete yet ...

now asking what exactly was the reason behind this parameter? f I remember correctly you said it was to compensate layout on small devices?

Leptopoda commented 2 years ago

@calcitem ?? could you please tell me the reason you did it this way? I'm planning to utilize the scaffolds AppBar to position our header. Is there anything against this? I'll open a PR for that so you can test it.

calcitem commented 2 years ago

The origin source of calcScreenPaddingH is from: https://github.com/hezhaoyun/chessroad/blob/0ef84b36fda5545f9e43357beec4754402a6068e/lib/routes/battle-page.dart#L298

The Chinese comment for this function translates to:

Limit the width of the board when the aspect ratio of the screen is less than 16/9

I have directly followed this part of the code and have not yet targeted it for testing.

  double get _screenPaddingH {
    // when screen's height/width rate is less than 16/9, limit width of board
    final windowSize = MediaQuery.of(context).size;
    final double height = windowSize.height;
    double width = windowSize.width;

    // TODO: [Leptopoda] maybe use windowSize.aspectRatio
    if (height / width < 16.0 / 9.0) {
      width = height * 9 / 16;
      return (windowSize.width - width) / 2 - AppTheme.boardMargin;
    } else {
      return AppTheme.boardScreenPaddingH;
    }
  }

I used ChessRoad's source code when some of it had not been thoroughly figured out and was just modified from the original code to Mill logic. I had previously contacted the author of ChessRoad, but he seemed to be very busy and could provide very few answers. So we have to do more of our analysis and do more testing later.

Leptopoda commented 2 years ago

Ok, I've rewritten the painters again to make the scaling easier and faster (the above code will probably go away thus fixing this error)

I have a few questions: what exactly should be displayed for the screen reader? There is quite a bit there and I think we could do with less. I guess every point should be annotated. but why is there also text in between the points? Like "no point"

Also what exactly is the reason for LocalDatabaseService.display.boardTop

Why not center it? Or why is the top also applied to the header? Shouldn't the header always stay in the top (like the app bar) and the board be centered (or offset by the value)?

calcitem commented 2 years ago

As mentioned in other issues before, the reading content of the existing screen reader is designed and defined by blind friends in Austria and cannot be changed. I will explain the specific reasons in detail in about 6 hours.

The reason why users are provided to configure the height of the board from the top is because different users have different preferences. Some people like to put the board at the bottom for easy tap, but some people think it is not beautiful.

calcitem commented 2 years ago

why is there also text in between the points? Like "no point"

I rechecked the records of previous emails with the blind player, and he commented that it would be better to make it an option that some people like and some may not like. I haven't added the option yet and will do so later after completing the infrastructure refactoring.

Here is some feedback from the blind player in an email. https://github.com/calcitem/Sanmill/discussions/457

calcitem commented 2 years ago

For your second question, I have added a post on Issue https://github.com/calcitem/Sanmill/issues/296.

calcitem commented 2 years ago

It looks like it has been fixed. (Commit 71248fc8)

calcitem commented 2 years ago

Close.

why is the top also applied to the header?

We can discuss Issue #296.