daohoangson / flutter_widget_from_html

Flutter package to render html as widgets that supports hyperlink, image, audio, video, iframe and many other tags.
https://pub.dev/packages/flutter_widget_from_html
MIT License
614 stars 226 forks source link

the HtmlWidget is too slow #933

Open xiaolei123 opened 1 year ago

xiaolei123 commented 1 year ago

Use case

HtmlWidget(
  html,
  buildAsync: true,
);

Proposal

i found you parsed html with main isolate ,:

Widget _buildSync() {
    Timeline.startSync('Build $widget (sync)');

    Widget built;
    try {
      final domNodes = _parseHtml(widget.html);
      built = _buildBody(this, domNodes);
    } catch (error, stackTrace) {
      built =
          _wf.onErrorBuilder(context, _rootMeta, error, stackTrace) ?? widget0;
    }

    Timeline.finishSync();

    return built;
  }

but _parseHtml(html) is too slow, can you use the Isolate.spow, in the child isolate,it's will be faster

daohoangson commented 1 year ago

How big is your HTML?

xiaolei123 commented 1 year ago

my html is small , but when i open a new page . and load html when i open new page .

but the page Transition animations has not finish, the HtmlWidget load html is success,

the app will be Stutter dropped frames.

daohoangson commented 1 year ago

So it was... too fast?

xiaolei123 commented 1 year ago

emm .... it like yes. and this scene have any method to fix it ? (the app will be Stutter dropped frames)

daohoangson commented 1 year ago

Can you share your HTML? With a medium size HTML or smaller, it should not impact navigation animation. Did you test in release mode?