fluttercommunity / fluttercommunity/flutter_webview_plugin

The webview got blocked when the there is some heavy computation in onMessageReceived.

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

説明

Hello,
I am using webview in my application, and I am using postmessages from communication and maintaining state between flutter app and webview.
The issue that I am struggling with is if there is some heavy computation is going on in onMessageReceived callback of JavascriptChannel then the webview stuck.

For Example:
```
javascriptChannels: [
JavascriptChannel(
name: 'Tts',
onMessageReceived: (JavascriptMessage msg) {
sleep(const Duration(seconds: 60)); <<-- something to mimic the computational delay.
ttsMessagesReceived.add(msg.message);
}),
].toSet(),
```
I was under impressions that webview has its own process and UI thread and flutter is executing in its own process. so, in that case this should not block each other.

Is there any way to make it async so that webview will continues its functioning smoothly and onMessageReceived will do its computation in parallel? I tried to wrap it with async / await but it didn't help..

Ref:
https://github.com/flutter/plugins/blob/master/packages/webview_flutter/test/webview_flutter_test.dart#L581

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

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

調査の方向性

まず、packages/webview_flutter/test/webview_flutter_test.dart の581行目付近にある参照先のテストから始め、次に、長時間実行されるcallbackを使用するonMessageReceivedの例で問題を再現します。callbackの実行中もwebviewが応答可能な状態を保ち、その動作をカバーするテストがある状態になれば、作業は完了です。

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

評価

技術スタック
dart, flutter, javascript
領域
mobile-dev
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

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

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