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

[BUG]Failed Assertion when URL is rendered #1019

Closed
jaredgreener opened this issue Feb 28, 2022 · 4 comments
Closed

[BUG]Failed Assertion when URL is rendered #1019

jaredgreener opened this issue Feb 28, 2022 · 4 comments
Assignees

Comments

@jaredgreener
Copy link

jaredgreener commented Feb 28, 2022

Describe the bug:
When including a link (<a href=""></a>) in the html content, I am getting an ambiguous bug:

'package:flutter/src/semantics/semantics.dart': Failed assertion: line 3023 pos 16: 'node.parent == null || !node.parent!.isPartOfNodeMerging || node.isMergedIntoParent': is not true.

When I remove the tag, everything functions normally. As soon as I add it back in, the bug returns.

HTML to reproduce the issue:

Today's lesson will be streamed via the following link:<div><br></div><div><a href="https://www.apple.com" rel="nofollow">Streaming Link</a><b><u></u></b><br></div>

Html widget configuration:

Widget buildEditable(){

    return Container(
        padding: const EdgeInsets.fromLTRB(8,5,8,5),
        child: Center(
            child: GestureDetector(
              onTap: (){
                _documentBloc.add(EditRichText(_node));
              },
              child: Container(
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(3.0),
                  boxShadow: <BoxShadow>[
                    BoxShadow(
                        color: Colors.black26,
                        offset: Offset(1, 2),
                        blurRadius: 1,
                        spreadRadius: 1)
                  ],
                ),
                child: Html(
                  data: _node.content,
                  shrinkWrap: true,
                  onLinkTap: (url, context, attributes, element) {
                    _documentBloc.add(EditRichText(_node));
                  },
                )
              ),
            )
        )
    );

Device details and Flutter/Dart/flutter_html versions:

iOS Simulator iPhone 12 Pro
flutter_html 3.0.0-alpha.2 (Was also produced in version 2.2.1)

Stacktrace/Logcat
======== Exception caught by scheduler library =====================================================
The following assertion was thrown during a scheduler callback:
'package:flutter/src/semantics/semantics.dart': Failed assertion: line 3023 pos 16: 'node.parent == null || !node.parent!.isPartOfNodeMerging || node.isMergedIntoParent': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack:
#2 SemanticsOwner.sendSemanticsUpdate (package:flutter/src/semantics/semantics.dart:3023:16)
#3 PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1098:24)
#4 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:502:21)
#5 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:883:13)
#6 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)
#7 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#8 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1081:9)
#9 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:995:5)
#13 _invoke (dart:ui/hooks.dart:151:10)
#14 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
#15 _drawFrame (dart:ui/hooks.dart:115:31)
(elided 5 frames from class _AssertionError and dart:async)

Additional info:
I am rendering multiple Containers with html in each container in rows...not sure if that is a problem to have multiple instances in one page.
screenshot2

@jaredgreener jaredgreener added the bug Something isn't working label Feb 28, 2022
@jaredgreener
Copy link
Author

This is part of a MUCH larger widget tree that I didn't include due to size and complexity. I started recreating the widget tree in a test project to narrow down the problem and was able to find the perpetrator. For some reason, an html widget containing a link (a tag) when inside a standard flutter Material "Reorderable List View" will trigger the error. See the minimal reproducible example:


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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key}) : super(key: key);
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin, WidgetsBindingObserver{

  final ScrollController reorderScrollController = ScrollController();

  Widget renderWidget(int index){

    return Container(
        key: ValueKey(index),
        padding: const EdgeInsets.fromLTRB(8,5,8,5),
        child: Html(
          data: "Today's lesson will be streamed via the following link:<div><br></div><div><a href='https://www.apple.com'>Streaming Link</a><b><u></u></b><br></div>",
          shrinkWrap: true,
          onLinkTap: (url, context, attributes, element) {
          },
        )
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: ReorderableListView(
        scrollController: reorderScrollController,
        onReorder: (int oldIndex, int newIndex){

        },
        children: [
          renderWidget(1),
        ],
      ),
    );
  }
}

Leads to:

======== Exception caught by scheduler library =====================================================
The following assertion was thrown during a scheduler callback:
'package:flutter/src/semantics/semantics.dart': Failed assertion: line 3023 pos 16: 'node.parent == null || !node.parent!.isPartOfNodeMerging || node.isMergedIntoParent': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack:
#2 SemanticsOwner.sendSemanticsUpdate (package:flutter/src/semantics/semantics.dart:3023:16)
#3 PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1098:24)
#4 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:502:21)
#5 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:883:13)
#6 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)
#7 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#8 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1081:9)
#9 SchedulerBinding.scheduleWarmUpFrame. (package:flutter/src/scheduler/binding.dart:862:7)
(elided 6 frames from class _AssertionError, class _RawReceivePortImpl, class _Timer, and dart:async-patch)

Reloaded 1 of 645 libraries in 254ms.

@Sub6Resources
Copy link
Owner

Thanks for the minimal reproducible example. I'll look into this. Clever app idea too, brother 😉

@Sub6Resources Sub6Resources self-assigned this Jun 10, 2022
@Sub6Resources Sub6Resources added this to the 3.0.0 milestone Aug 20, 2022
@Sub6Resources
Copy link
Owner

After some investigation, I've had to forward this issue onto the Flutter team, as it turns out to be an issue with Flutter itself.

You can follow flutter/flutter#126840 for updates.

@Sub6Resources Sub6Resources removed this from the 3.0.0 milestone May 15, 2023
@Sub6Resources Sub6Resources added flutter-issue and removed bug Something isn't working labels May 15, 2023
@Sub6Resources
Copy link
Owner

This issue has been fixed in the Flutter master branch. Since the assertion doesn't cause a crash and since flutter_html is not at fault, I'm closing this.

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

No branches or pull requests

2 participants