fluttercommunity / fluttercommunity/flutter_webview_plugin

Bad performance of WebviewScaffold

Aperta
#386 0 commenti 7 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
1.5k
Fork
938
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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!

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.