fluttercommunity / fluttercommunity/flutter_webview_plugin
Js code contains timer, exit webvie_scaffold, and the timer still runs.
- Langage dominant
- Java
- Étoiles
- 1.5k
- Forks
- 936
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
I use the webview_scaffold to open a web.
the webpage contains contains a timer.
this is a html file I have used:
```
Timer
var s;
function $(id){
return document.getElementById(id);
}
function display(){
var date = new Date();
var str = date.getTime();
$("content").value = str;
console.log("this this a console log..." + str);
s = setTimeout('display()',1000);
}
window.onload = function(){
$("start").onclick =function(){display();}
$("stop").onclick = function(){clearTimeout(s);}
}
```
It means that change the display num and print some log per second.
this is my webviewPage.dart
```
//! WebViewPage
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
class AppWebView extends StatelessWidget {
final String url;
final String title;
AppWebView(this.url, this.title);
_renderTitle() {
if (url == null || url.length == 0) {
return new Text(title);
}
return new Row(children: [
//new Expanded(child: new Container()),
new Text(title)
]);
}
@override
Widget build(BuildContext context) {
return new WebviewScaffold(
withJavascript: true,
hidden: false,
url: url,
scrollBar:false,
withLocalUrl: true,
appBar: new AppBar(
title: _renderTitle(),
),
);
}
}
```
when I open the webview to the html file,then I press the start button on this web.Finally I exit the webview.
this is my log:
```
I/flutter ( 4095): 运维页面
I/zygote64( 4095): Compiler allocated 8MB to compile void android.view.ViewRootImpl.performTraversals()
D/ViewRootImpl@d8ee1fe[MainActivity]( 4095): ViewPostIme pointer 0
D/ViewRootImpl@d8ee1fe[MainActivity]( 4095): ViewPostIme pointer 1
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273611702", source: http://192.168.10.104/test.html (24)
V/InputMethodManager( 4095): Starting input: tba=android.view.inputmethod.EditorInfo@560ef34 nm : com.example.dfelectricapp ic=null
I/InputMethodManager( 4095): startInputInner - mService.startInputOrWindowGainedFocus
D/InputMethodManager( 4095): HSIFW - flag : 0 Pid : 4095
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273612709", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273613719", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273614726", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273615730", source: http://192.168.10.104/test.html (24)
D/ViewRootImpl@d8ee1fe[MainActivity]( 4095): ViewPostIme pointer 0
D/ViewRootImpl@d8ee1fe[MainActivity]( 4095): ViewPostIme pointer 1
I/flutter ( 4095): 运维页面show web
I/flutter ( 4095): this is webview dispose
D/InputMethodManager( 4095): HSIFW - flag : 0 Pid : 4095
V/InputMethodManager( 4095): Starting input: tba=android.view.inputmethod.EditorInfo@95fe15d nm : com.example.dfelectricapp ic=null
I/InputMethodManager( 4095): startInputInner - mService.startInputOrWindowGainedFocus
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273617383", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273619384", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273621385", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273623384", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273625384", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273627383", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273629384", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273631384", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273633385", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273635384", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273637385", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273639385", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273641385", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273643385", source: http://192.168.10.104/test.html (24)
I/chromium( 4095): [INFO:CONSOLE(24)] "this this a console log...1545273645385", source: http://192.168.10.104/test.html (24)
```
You can see that I've quit the webview but the log is still being printed.
I try to solve this problem.So here's what I did.
In the webview_scaffold.dart
```
@override
void dispose() {
super.dispose();
webviewReference.reloadUrl(""); //! I add this line
_resizeTimer?.cancel();
webviewReference.close();
if (widget.hidden) {
_onStateChanged.cancel();
}
print("this is webview dispose");
webviewReference.dispose();
}
```
It worked,But I don't know the reason.
Am I right?
I want to know why the js consle log still being printed.
Thanks very much.
btw:
this is flutter doctor print:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.11.7, on Microsoft Windows [Version 10.0.17134.471], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[√] Android Studio (version 3.2)
[√] Connected device (1 available)
• No issues found!
this is the dependencies:
flutter_webview_plugin: ^0.3.0+2
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Reproduisez le problème avec le minuteur HTML fourni et webviewPage.dart, puis examinez le cycle de vie de WebviewScaffold dans webview_scaffold.dart, en particulier dispose et la gestion de webviewReference. Déterminez pourquoi JavaScript continue à journaliser des messages après la fermeture du scaffold. La tâche est terminée lorsque le minuteur s’arrête à la sortie de la webview sans dépendre du workaround reloadUrl ajouté, et que le comportement du cycle de vie est documenté ou couvert par un test approprié, s’il en existe un.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- android, dart, flutter, javascript
- Domaine
- mobile, web-dev
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100