fluttercommunity / fluttercommunity/flutter_webview_plugin

Bad performance of WebviewScaffold

オープン
#386 コメント 0 件 リアクション 7 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
1.5k
フォーク
938
PR マージ指標
30日以内にマージされた PR はありません

説明

I noticed a relatively high CPU consumption when using the WebviewScaffold. It happens even when there are no changes within the WebView. The flutter performance profiler shows that there 60 frames per second updated despite no visible state changes.

After some investigation I've found that the culprit is the default initial child instantiated in webview_scaffold.dart line 148

```dart
child: widget.initialChild ?? const Center(child: const CircularProgressIndicator()),
```

It looks like this animated widget stays running all the time even when it's not visible. A simple workaround was to provide

```dart
initialChild: Container(),
```
in the WebviewScaffold constructor. It definitely fixes the issue with frame updates and high CPU load and subjectively makes the WebView working smoother.

I'm not sure what's the best way of fixing it. Perhaps having an empty initial child by default or removing this child when a page is loaded. But some changes seems to be necessary.

BTW, thanks for the great plugin!

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Read webview_scaffold.dart around line 148 and inspect how the default initialChild is used compared with the explicit Container() workaround. Reproduce the WebviewScaffold case with Flutter's performance profiler, then verify that the unnecessary 60 FPS updates and high CPU consumption no longer occur when the WebView has no visible changes.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
dart, flutter
領域
mobile
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。