fluttercommunity / fluttercommunity/flutter_webview_plugin

Bad performance of WebviewScaffold

Open
#386 0 comments 7 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.5k
Forks
938
PR merge metrics
No merged PRs in 30d

Description

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!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.