Open timbru31 opened 4 years ago
I added the below code in PDFGenerator.java
public WebView getOffscreenWebkitInstance(Context ctx) {
LOG.i(APPNAME, "Mounting offscreen webview");
if(this.offscreenWebview !=null){
this.offscreenWebview.destroy();
this.offscreenWebview = null;
}
if (this.offscreenWebview == null){
WebView view = new WebView(ctx);
view.getSettings().setDatabaseEnabled(true);
view.getSettings().setJavaScriptEnabled(true);
return this.offscreenWebview = view;
}else{
return this.offscreenWebview;
}
}
I just destroyed the webView
My approach is/was to destroy the actual instance once the onFinish
is called: https://github.com/cesarvr/pdf-generator/pull/125/files#r488642327 - otherwise you have a stale offScreenWebView that is only destroyed on the next print.
^^ yea thats very much valid. I destroyed it in onFinish .
Hello. Is this fix released? This problem fits the symptoms my users are reporting - and which I can replicate with a simple
You could use our fork as an intermediate solution: https://www.npmjs.com/package/@d2d/cordova-pdf-generator
Thanks Tim, lifesaver.
From: Tim Brust notifications@github.com Sent: Wednesday, 14 October 2020 10:35 pm To: cesarvr/pdf-generator pdf-generator@noreply.github.com Cc: ascottk scottka@dbsys.co.nz; Comment comment@noreply.github.com Subject: Re: [cesarvr/pdf-generator] Crashes with Chrome 86+ on Android (#124)
You could use our fork as an intermediate solution: https://www.npmjs.com/package/@d2d/cordova-pdf-generator
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cesarvr/pdf-generator/issues/124#issuecomment-708283973 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACF4OJTLKB23HJNHEHWDCRTSKVWE3ANCNFSM4RNB3RJA .
-- This email has been checked for viruses by AVG. https://www.avg.com
We are experiencing crashes (with the
base64
option) and faulty previews (with theshare
option) when using Chrome's 86 beta version (86.0.4240.30) or higher (Canary (87.0.4262.3) is affected, too).I've narrowed the behaviour down to the webview behvaior. The same webView is re-used and never destoryed, leading to the above bug description on the second call from the plugin. When destroying the WebView, i.e., always using a fresh one, the bug is fixed.
A pull request will follow shortly, which includes a general cleanup of the Java code.
For the completeness, here are the version information: Android 9 on a Lenovo TB-X505F.
cordova info
```txt Cordova Packages: cli: 10.0.0 common: 4.0.2 create: 3.0.0 lib: 10.0.0 common: 4.0.2 fetch: 3.0.0 serve: 4.0.0 Project Installed Platforms: android: 9.0.0 Project Installed Plugins: cordova-android-support-gradle-release: 3.0.1 cordova-open-native-settings: 1.5.2 cordova-pdf-generator: 2.1.1 cordova-plugin-androidx-adapter: 1.1.1 cordova-plugin-app-version: 0.1.9 cordova-plugin-badge: 0.8.8 cordova-plugin-calendar: 5.1.5 cordova-plugin-delete-launch-screen-cache: 1.0.1 cordova-plugin-device: 2.0.3 cordova-plugin-dialogs: 2.0.2 cordova-plugin-file-opener2: 3.0.4 cordova-plugin-file-transfer: 2.0.0 cordova-plugin-file: 6.0.2 cordova-plugin-geolocation: 4.0.2 cordova-plugin-inappbrowser: 4.0.0 cordova-plugin-ionic-keyboard: 2.2.0 cordova-plugin-ionic-webview: 5.0.0 cordova-plugin-ionic: 5.4.7 cordova-plugin-local-notification: 0.9.0-beta.3 cordova-plugin-lottie-splashscreen: 0.9.0 cordova-plugin-network-information: 2.0.2 cordova-plugin-pincheck: 0.0.6 cordova-plugin-screen-orientation: 3.0.2 cordova-plugin-secure-storage-echo: 5.1.1 cordova-plugin-statusbar: 2.4.3 cordova-plugin-whitelist: 1.3.4 cordova-plugin-x-toast: 2.7.2 cordova-plugin-zip: 5.0.0 es6-promise-plugin: 4.2.2 Environment: OS: macOS Catalina 10.15.6 (19G2021) (darwin 19.6.0) x64 Node: v12.18.3 npm: 6.14.6 android Environment: android: ************************************************************************* The "android" command is deprecated. For manual SDK, AVD, and project management, please use Android Studio. For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager ************************************************************************* Running /Users/tim.brust/Library/Android/sdk/tools/bin/avdmanager list target Available Android targets:==============] 100% Fetch remote repository... ---------- id: 1 or "android-28" Name: Android API 28 Type: Platform API level: 28 Revision: 6 ---------- id: 2 or "android-29" Name: Android API 29 Type: Platform API level: 29 Revision: 5 Project Setting Files: config.xml: