Skip to content
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

LineChartBarData crash if shadow applied on iOS #1466

Closed
joselicht90 opened this issue Oct 24, 2023 · 2 comments · Fixed by #1485
Closed

LineChartBarData crash if shadow applied on iOS #1466

joselicht90 opened this issue Oct 24, 2023 · 2 comments · Fixed by #1485
Labels
bug Something isn't working Line Chart

Comments

@joselicht90
Copy link

Describe the bug
I've found that if I applied a Shadow to LineChartBarData that only has one FlSpot, the app will crash. This didn't happened to me before upgrading to latest flutter and lates package version.

To Reproduce

import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: LineChart(
          LineChartData(
            borderData: FlBorderData(
              show: false,
            ),
            minX: 0,
            maxX: 7,
            minY: -15,
            maxY: 100,
            lineTouchData: LineTouchData(
              getTouchedSpotIndicator: (barData, spotIndexes) {
                return spotIndexes.map((spotIndex) {
                  const color = Colors.red;
                  return const TouchedSpotIndicatorData(
                    FlLine(
                      color: color,
                      dashArray: [5, 10],
                      strokeWidth: 2,
                    ),
                    FlDotData(
                      show: true,
                    ),
                  );
                }).toList();
              },
            ),
            lineBarsData: [
              LineChartBarData(
                spots: [
                  FlSpot(2, 50),
                ],
                isCurved: true,
                shadow: Shadow(
                  color: Colors.black.withOpacity(0.55),
                  offset: const Offset(0, 5),
                  blurRadius: 4,
                ),
                color: Colors.red,
                barWidth: 4,
                isStrokeCapRound: false,
                show: true,
                curveSmoothness: 0,
                dotData: FlDotData(
                  show: true,
                  getDotPainter: (p0, p1, p2, p3) {
                    return FlDotCirclePainter(
                      radius: 6,
                      color: Colors.black,
                      strokeWidth: 2,
                      strokeColor: Colors.red,
                    );
                  },
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Error Output from Runner


Translated Report (Full Report Below)

Incident Identifier: 9A1C5569-1BC7-471A-8A58-90D06A58250A
CrashReporter Key: 62A92737-781F-1C27-DF6B-054C7C520EA5
Hardware Model: MacBookAir10,1
Process: Runner [30919]
Path: /Users/USER/Library/Developer/CoreSimulator/Devices/F040D457-DE2D-4C0D-ABA1-ABBF13129FEF/data/Containers/Bundle/Application/AA2F6E33-B262-4D76-8F85-13E4EB3C6DEA/Runner.app/Runner
Identifier: com.galvans.staging
Version: 1.7.0 (203)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd_sim [99043]
Coalition: com.apple.CoreSimulator.SimDevice.F040D457-DE2D-4C0D-ABA1-ABBF13129FEF [26338]
Responsible Process: SimulatorTrampoline [1426]

Date/Time: 2023-10-24 14:22:20.0614 -0300
Launch Time: 2023-10-24 14:21:39.2994 -0300
OS Version: macOS 14.0 (23A344)
Release Type: User
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes: 0x0000000000000001, 0x0000000000000000
VM Region Info: 0 is not in any region. Bytes before following region: 4372971520
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 104a64000-104b94000 [ 1216K] r-x/r-x SM=COW ...er.app/Runner
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [30919]

Thread 4 Crashed:: io.flutter.1.raster
0 Flutter 0x1092fe8d0 impeller::ContentsFilterInput::GetCoverage(impeller::Entity const&) const + 4
1 Flutter 0x1092fbf4c impeller::DirectionalGaussianBlurFilterContents::GetFilterCoverage(std::_LIBCPP_ABI_NAMESPACE::vector<std::_LIBCPP_ABI_NAMESPACE::shared_ptrimpeller::FilterInput, std::_LIBCPP_ABI_NAMESPACE::allocator<std::_LIBCPP_ABI_NAMESPACE::shared_ptrimpeller::FilterInput>> const&, impeller::Entity const&, impeller::Matrix const&) const + 80
2 Flutter 0x1092fae6c impeller::FilterContents::GetLocalCoverage(impeller::Entity const&) const + 52
3 Flutter 0x1092faf64 impeller::FilterContents::GetCoverage(impeller::Entity const&) const + 156
4 Flutter 0x1092fbf4c impeller::DirectionalGaussianBlurFilterContents::GetFilterCoverage(std::_LIBCPP_ABI_NAMESPACE::vector<std::_LIBCPP_ABI_NAMESPACE::shared_ptrimpeller::FilterInput, std::_LIBCPP_ABI_NAMESPACE::allocator<std::_LIBCPP_ABI_NAMESPACE::shared_ptrimpeller::FilterInput>> const&, impeller::Entity const&, impeller::Matrix const&) const + 80
5 Flutter 0x1092fae6c impeller::FilterContents::GetLocalCoverage(impeller::Entity const&) const + 52
6 Flutter 0x1092faf64 impeller::FilterContents::GetCoverage(impeller::Entity const&) const + 156
7 Flutter 0x10931a658 impeller::EntityPass::GetElementsCoverage(std::_LIBCPP_ABI_NAMESPACE::optional<impeller::TRect>) const + 96
8 Flutter 0x10931a7a4 impeller::EntityPass::GetSubpassCoverage(impeller::EntityPass const&, std::_LIBCPP_ABI_NAMESPACE::optional<impeller::TRect>) const + 56
9 Flutter 0x10931c8d4 impeller::EntityPass::GetEntityForElement(std::_LIBCPP_ABI_NAMESPACE::variant<impeller::Entity, std::_LIBCPP_ABI_NAMESPACE::unique_ptr<impeller::EntityPass, std::_LIBCPP_ABI_NAMESPACE::default_deleteimpeller::EntityPass>> const&, impeller::ContentContext&, impeller::InlinePassContext&, impeller::TSize, impeller::TPoint, unsigned int, std::_LIBCPP_ABI_NAMESPACE::vector<impeller::EntityPass::StencilCoverageLayer, std::_LIBCPP_ABI_NAMESPACE::allocatorimpeller::EntityPass::StencilCoverageLayer>&, unsigned long) const + 1196
10 Flutter 0x10931bd00 impeller::EntityPass::OnRender(impeller::ContentContext&, impeller::TSize, impeller::EntityPassTarget&, impeller::TPoint, impeller::TPoint, unsigned int, std::_LIBCPP_ABI_NAMESPACE::vector<impeller::EntityPass::StencilCoverageLayer, std::_LIBCPP_ABI_NAMESPACE::allocatorimpeller::EntityPass::StencilCoverageLayer>&, unsigned long, std::_LIBCPP_ABI_NAMESPACE::shared_ptrimpeller::Contents, std::_LIBCPP_ABI_NAMESPACE::optionalimpeller::InlinePassContext::RenderPassResult const&) const + 1000
11 Flutter 0x10931b220 impeller::EntityPass::Render(impeller::ContentContext&, impeller::RenderTarget const&) const + 2180
12 Flutter 0x1093362f4 impeller::Renderer::Render(std::_LIBCPP_ABI_NAMESPACE::unique_ptr<impeller::Surface, std::_LIBCPP_ABI_NAMESPACE::default_deleteimpeller::Surface>, std::_LIBCPP_ABI_NAMESPACE::function<bool (impeller::RenderTarget&)> const&) const + 320
13 Flutter 0x1093d0db4 std::_LIBCPP_ABI_NAMESPACE::__function::__func<fml::internal::CopyableLambda<flutter::GPUSurfaceMetalImpeller::AcquireFrameFromCAMetalLayer(SkISize const&)::$_0>, std::_LIBCPP_ABI_NAMESPACE::allocator<fml::internal::CopyableLambda<flutter::GPUSurfaceMetalImpeller::AcquireFrameFromCAMetalLayer(SkISize const&)::$_0>>, bool (flutter::SurfaceFrame&, flutter::DlCanvas*)>::operator()(flutter::SurfaceFrame&, flutter::DlCanvas*&&) + 740
14 Flutter 0x109290b14 flutter::SurfaceFrame::Submit() + 92
15 Flutter 0x1091c1e4c flutter::Rasterizer::DrawToSurfaceUnsafe(flutter::FrameTimingsRecorder&, flutter::LayerTree&, float) + 1308
16 Flutter 0x1091c3cf4 std::_LIBCPP_ABI_NAMESPACE::__function::__func<flutter::Rasterizer::DrawToSurface(flutter::FrameTimingsRecorder&, flutter::LayerTree&, float)::$_1, std::_LIBCPP_ABI_NAMESPACE::allocator<flutter::Rasterizer::DrawToSurface(flutter::FrameTimingsRecorder&, flutter::LayerTree&, float)::$_1>, void ()>::operator()() + 36
17 Flutter 0x1090b25ac fml::SyncSwitch::Execute(fml::SyncSwitch::Handlers const&) const + 72
18 Flutter 0x1091c04c4 flutter::Rasterizer::DrawToSurface(flutter::FrameTimingsRecorder&, flutter::LayerTree&, float) + 308
19 Flutter 0x1091c123c flutter::Rasterizer::DoDraw(std::_LIBCPP_ABI_NAMESPACE::unique_ptr<flutter::FrameTimingsRecorder, std::_LIBCPP_ABI_NAMESPACE::default_deleteflutter::FrameTimingsRecorder>, std::_LIBCPP_ABI_NAMESPACE::unique_ptr<flutter::LayerTree, std::_LIBCPP_ABI_NAMESPACE::default_deleteflutter::LayerTree>, float) + 184
20 Flutter 0x1091c283c std::_LIBCPP_ABI_NAMESPACE::__function::__func<flutter::Rasterizer::Draw(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::Pipelineflutter::LayerTreeItem> const&, std::_LIBCPP_ABI_NAMESPACE::function<bool (flutter::LayerTree&)>)::$_1, std::_LIBCPP_ABI_NAMESPACE::allocator<flutter::Rasterizer::Draw(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::Pipelineflutter::LayerTreeItem> const&, std::_LIBCPP_ABI_NAMESPACE::function<bool (flutter::LayerTree&)>)::$_1>, void (std::_LIBCPP_ABI_NAMESPACE::unique_ptr<flutter::LayerTreeItem, std::_LIBCPP_ABI_NAMESPACE::default_deleteflutter::LayerTreeItem>)>::operator()(std::_LIBCPP_ABI_NAMESPACE::unique_ptr<flutter::LayerTreeItem, std::_LIBCPP_ABI_NAMESPACE::default_deleteflutter::LayerTreeItem>&&) + 148
21 Flutter 0x1091c0c74 flutter::Pipelineflutter::LayerTreeItem::Consume(std::_LIBCPP_ABI_NAMESPACE::function<void (std::_LIBCPP_ABI_NAMESPACE::unique_ptr<flutter::LayerTreeItem, std::_LIBCPP_ABI_NAMESPACE::default_deleteflutter::LayerTreeItem>)> const&) + 188
22 Flutter 0x1091c0690 flutter::Rasterizer::Draw(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::Pipelineflutter::LayerTreeItem> const&, std::_LIBCPP_ABI_NAMESPACE::function<bool (flutter::LayerTree&)>) + 148
23 Flutter 0x1091d5d10 std::_LIBCPP_ABI_NAMESPACE::__function::__func<fml::internal::CopyableLambda<flutter::Shell::OnAnimatorDraw(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::Pipelineflutter::LayerTreeItem>)::$_0>, std::_LIBCPP_ABI_NAMESPACE::allocator<fml::internal::CopyableLambda<flutter::Shell::OnAnimatorDraw(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::Pipelineflutter::LayerTreeItem>)::$_0>>, void ()>::operator()() + 140
24 Flutter 0x1090af494 fml::MessageLoopImpl::FlushTasks(fml::FlushType) + 156
25 Flutter 0x1090b5dc0 fml::MessageLoopDarwin::OnTimerFire(__CFRunLoopTimer*, fml::MessageLoopDarwin*) + 32
26 CoreFoundation 0x1803eed9c CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 28
27 CoreFoundation 0x1803eea58 __CFRunLoopDoTimer + 948
28 CoreFoundation 0x1803ee0f4 __CFRunLoopDoTimers + 284
29 CoreFoundation 0x1803e8840 __CFRunLoopRun + 1796
30 CoreFoundation 0x1803e7d28 CFRunLoopRunSpecific + 572
31 Flutter 0x1090b5ef0 fml::MessageLoopDarwin::Run() + 88
32 Flutter 0x1090af3a8 fml::MessageLoopImpl::DoRun() + 40
33 Flutter 0x1090b4a20 void* std::_LIBCPP_ABI_NAMESPACE::__thread_proxy[abi:v15000]<std::_LIBCPP_ABI_NAMESPACE::tuple<std::_LIBCPP_ABI_NAMESPACE::unique_ptr<std::_LIBCPP_ABI_NAMESPACE::__thread_struct, std::_LIBCPP_ABI_NAMESPACE::default_deletestd::_LIBCPP_ABI_NAMESPACE::__thread_struct>, fml::Thread::Thread(std::_LIBCPP_ABI_NAMESPACE::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0>>(void*) + 208
34 libsystem_pthread.dylib 0x10637f4c0 _pthread_start + 104
35 libsystem_pthread.dylib 0x10637a6f0 thread_start + 8

Versions

  • Flutter 3.13.8
  • FlChart 0.64.0
@ChatchaiBuekban
Copy link

ChatchaiBuekban commented Nov 10, 2023

I got same error only iOS crash when data length is 1.
my fixed

          shadow: spotsList.length >= 2
              ? Shadow(blurRadius: 4, color: Color(0xFF536DFE).withOpacity(0.5))
              : const Shadow(color: Colors.transparent),

@imaNNeo
Copy link
Owner

imaNNeo commented Nov 24, 2023

Fixed in 0.65.0
Check it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Line Chart
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants