Skip to content

[syncfusion_flutter_charts] NoSuchMethodError in SfCircularChartState #13

Closed

Description

@kinex

Crash in syncfusion_flutter_charts 18.3.38
NoSuchMethodError: The getter 'iterator' was called on null. Receiver: null Tried calling: iterator. Error thrown Instance of 'ErrorDescription'. _GrowableList.addAll

Crashed: pool-16-thread-6
       at _GrowableList.addAll(_GrowableList.java)
       at SfCircularChartState._createAndUpdateSeriesRenderer(SfCircularChartState.java:808)
       at SfCircularChartState.didUpdateWidget(SfCircularChartState.java:627)
       at StatefulElement.update(StatefulElement.java:4815)
       at Element.updateChild(Element.java:3314)
       at ComponentElement.performRebuild(ComponentElement.java:4652)

Activity

  1. SriramKiranSenthilkumar commented on Oct 12, 2020

    @SriramKiranSenthilkumar
    Contributor

    Hi @kinex,

    Greetings from Syncfusion. We have analyzed your scenario and we tried to replicate the reported issue at our end regarding the circular chart throwing “NoSuchMethodError: The getter 'iterator' was called on null. Receiver: null Tried calling: iterator. Error thrown Instance of 'ErrorDescription'. _GrowableList.addAll” exception. Unfortunately, we were not able to replicate the reported issue. Since we are not aware of the exact scenario on which the issue is replicating, we request you to kindly revert us with replication steps/procedure to reproduce the reported issue or if possible, share us with a simple replication sample so that it will help provide the solutions sooner.

    Regards,
    Sriram Kiran

  2. kinex commented on Oct 12, 2020

    @kinex
    Author

    Hi @SriramKiranSenthilkumar,

    I see this crash from Crashlytics, but I cannot reproduce the issue myself. The crash seems to happen very often (one of the top crashes in my app currently). I am quite sure I didn't see this exception with the previous syncfusion_flutter_charts version 18.2.59.

    I guess this is the related code in my app:

      @override
      Widget build(BuildContext context) {
            .
            .
            .
            return SfCircularChart(
              legend: Legend(
                isVisible: true,
                position: LegendPosition.bottom,
              ),
              series: series,
            );
          }
        }

    So there is nothing special in my code.

  3. SriramKiranSenthilkumar commented on Oct 13, 2020

    @SriramKiranSenthilkumar
    Contributor

    Hi @kinex,

    We tried to replicate the reported issue with the provided information and we are sorry that we are not able to replicate the reported issue at our end. So, we kindly request you to share us with simple replication sample to replicate the reported issue and also provide us with the widget true structure you are using in your Flutter project as we are not exactly sure on what scenario the issue is replicating, or if possible try to replicate the reported issue with below test sample and revert us with that sample so that it will be helpful in providing the solutions sooner.

    Test sample: sample.zip

    Regards,
    Sriram kiran

  4. kinex commented on Oct 13, 2020

    @kinex
    Author

    I cannot reproduce this either myself. It is a big project so I cannot publish sources here, but here is some related code:

    class _Chart extends StatelessWidget {
      _Chart({Key key, this.viewModel})
          : series = [
              PieSeries<PieChartDataItem, String>(
                animationDuration: 0,
                name: viewModel.title,
                explode: false,
                explodeIndex: 0,
                explodeOffset: '10%',
                dataSource: (viewModel as IPieChartViewModel).pieChartData,
                xValueMapper: (PieChartDataItem data, _) => data.category,
                yValueMapper: (PieChartDataItem data, _) => data.value,
                dataLabelMapper: (PieChartDataItem data, _) => data.labelText,
                startAngle: 0,
                endAngle: 0,
                dataLabelSettings: DataLabelSettings(
                  isVisible: true,
                ),
              ),
            ],
            super(key: key);
    
      final BaseChartViewModel viewModel;
      final List<PieSeries<PieChartDataItem, String>> series;
    
      @override
      Widget build(BuildContext context) {
        if (viewModel.isLoading) {
          return Center(
            child: CircularProgressIndicator(),
          );
        } else {
          final pieCharViewModel = viewModel as IPieChartViewModel;
    
          if (pieCharViewModel?.pieChartData == null ||
              pieCharViewModel.pieChartData.isEmpty) {
            return NoDataView(
              text: pieCharViewModel.noDataToPlotMessage,
              useSmallFont: true,
            );
          } else {
            return SfCircularChart(
              legend: Legend(
                isVisible: true,
                position: LegendPosition.bottom,
              ),
              series: series,
            );
          }
        }
      }
    }

    Does that give you any idea what is wrong?

    I had a quick look into your sources. Here is the code where the crash occurs (circular_base.dart, line 806-)

            _prevSeriesRenderer._oldRenderPoints = <ChartPoint<dynamic>>[]
              //ignore: prefer_spread_collections
              ..addAll(_prevSeriesRenderer._renderPoints); // exception happens here

    For some reason _prevSeriesRenderer._renderPoints is null when it crashes. So this would fix it:

            _prevSeriesRenderer._oldRenderPoints = <ChartPoint<dynamic>>[]
              //ignore: prefer_spread_collections
              ..addAll(_prevSeriesRenderer._renderPoints ?? []); // exception happens here

    Not sure if that is a proper fix, or should you investigate why _prevSeriesRenderer._renderPoints is null.

  5. SriramKiranSenthilkumar commented on Oct 15, 2020

    @SriramKiranSenthilkumar
    Contributor

    Hi @kinex ,

    We have analyzed the reported issue with the provided information and still, we couldn't able to reproduce the reported issue at our end. However, we have made some analysis on the reported issue with the reported crashed code in our chart source at our end and we have provided a null check condition to check on the _prevSeriesRenderer before adding all the _prevSeriesRenderer._renderPoints into the growable list and these changes will be included in our upcoming weekly patch release which is expected to be rolled out the middle of next week. We will update you once the release is rolled out and we appreciate your patience until then.

    Regards,
    Sriram Kiran

  6. kinex commented on Oct 16, 2020

    @kinex
    Author

    Thank you for investigating this. Maybe it is some timing related issue making it very hard to reproduce. Waiting for the fix!

  7. SriramKiranSenthilkumar commented on Oct 29, 2020

    @SriramKiranSenthilkumar
    Contributor

    Hi @kinex,

    Thanks for your patience. We have now included the null check condition for avoiding the reported crash issue in our chart source in our weekly patch release. To overcome the reported issue kindly upgrade the chart widget package to the latest version below.
    https://pub.dev/packages/syncfusion_flutter_charts/versions/18.3.44

    Please get in touch with us if you would require further assistance.

    Regards,
    Sriram Kiran

  8. kinex commented on Oct 29, 2020

    @kinex
    Author

    Great, thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions