Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes with Chrome 86+ on Android #124

Open
timbru31 opened this issue Sep 15, 2020 · 6 comments · May be fixed by #125
Open

Crashes with Chrome 86+ on Android #124

timbru31 opened this issue Sep 15, 2020 · 6 comments · May be fixed by #125

Comments

@timbru31
Copy link
Contributor

timbru31 commented Sep 15, 2020

We are experiencing crashes (with the base64 option) and faulty previews (with the share 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
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:
<?xml version='1.0' encoding='utf-8'?>
<widget defaultlocale="de_DE" id="de.unitymedia.d2d.debug" ios-CFBundleVersion="13" version="3.0.3"
    xmlns="http://www.w3.org/ns/widgets"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>DEBUG-D2D</name>
    <description>App for supporting the mobile sales team.</description>
    <author email="[email protected]" href="https://sinnerschrader.com">SinnerSchrader Deutschland GmbH</author>
    <content src="index.html" />
    <access origin="https://d2d-dev.s2betrieb.de" />
    <access origin="https://d2d.unitymedia.de" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="mailto:*" />
    <feature name="CDVWKWebViewEngine">
        <param name="ios-package" value="CDVWKWebViewEngine" />
    </feature>
    <feature name="StatusBar">
        <param name="ios-package" onload="true" value="CDVStatusBar" />
    </feature>
    <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
    <preference name="AppendUserAgent" value="D2D-App/3.0.3" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="StatusBarOverlaysWebview" value="false" />
    <preference name="KeyboardShrinksView" value="true" />
    <preference name="ScrollEnabled" value="true" />
    <preference name="StatusBarBackgroundColor" value="#E60000" />
    <preference name="StatusBarStyle" value="lightcontent" />
    <preference name="LottieBackgroundColor" value="#E60000" />
    <preference name="LottieFullScreen" value="true" />
    <platform name="android">
        <allow-intent href="market:*" />
        <allow-navigation href="https://d2d/*"/>
        <hook src="scripts/cordova/fix_min_sdk_version.js" type="before_build" />
        <hook src="scripts/cordova/ionic_aab_support.sh" type="after_build" />
        <preference name="GradlePluginKotlinEnabled" value="true" />
        <preference name="AndroidXEnabled" value="true" />
        <preference name="SplashMaintainAspectRatio" value="true" />
        <preference name="android-minSdkVersion" value="24" />
        <preference name="MixedContentMode" value="1" />
        <preference name="Hostname" value="d2d" />
        <preference name="Scheme" value="https" />
        <preference name="LottieEnableHardwareAcceleration" value="true" />
        <preference name="LottieAnimationLocation" value="www/assets/lottie/android.json" />
        <preference name="LottieImagesLocation" value="www/assets/lottie/images" />
        <preference name="LottieScaleType" value="CENTER_CROP" />
        <icon density="mdpi" src="www/static/images/appicons/48x48.png" />
        <icon density="hdpi" src="www/static/images/appicons/72x72.png" />
        <icon density="xhdpi" src="www/static/images/appicons/96x96.png" />
        <icon density="xxhdpi" src="www/static/images/appicons/144x144.png" />
        <icon density="xxxhdpi" src="www/static/images/appicons/192x192.png" />
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/supports-screens">
            <supports-screens android:largeScreens="true" android:normalScreens="false" android:requiresSmallestWidthDp="600" android:smallScreens="false" android:xlargeScreens="true" />
        </edit-config>
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
            <application android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" />
        </edit-config>
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity[@android:label='@string/activity_name']" >
            <activity android:theme="@style/Theme.WhiteFullScreen"></activity>
        </edit-config>
        <resource-file src="www/static/images/android/theme.xml" target="app/src/main/res/values/themes.xml" />
        <resource-file src="www/static/images/appicons/android/drawable/ic_launcher_foreground.xml" target="app/src/main/res/drawable/ic_launcher_foreground.xml" />
        <resource-file src="www/static/images/appicons/android/drawable-v24/ic_launcher_background.xml" target="app/src/main/res/drawable-v24/ic_launcher_background.xml" />
        <resource-file src="www/static/images/appicons/android/mipmap-anydpi-v26/ic_launcher.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" />
        <resource-file src="www/static/images/appicons/android/mipmap-anydpi-v26/ic_launcher_round.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" />
        <resource-file src="www/static/images/appicons/android/mipmap-hdpi/ic_launcher.png" target="app/src/main/res/mipmap-hdpi/ic_launcher.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-hdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-hdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-hdpi/ic_launcher_round.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-mdpi/ic_launcher.png" target="app/src/main/res/mipmap-mdpi/ic_launcher.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-mdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-mdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-mdpi/ic_launcher_round.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-xhdpi/ic_launcher.png" target="app/src/main/res/mipmap-xhdpi/ic_launcher.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-xhdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-xhdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-xhdpi/ic_launcher_round.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-xxhdpi/ic_launcher.png" target="app/src/main/res/mipmap-xxhdpi/ic_launcher.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-xxhdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-xxhdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-xxxhdpi/ic_launcher.png" target="app/src/main/res/mipmap-xxxhdpi/ic_launcher.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-xxxhdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png" />
        <resource-file src="www/static/images/appicons/android/mipmap-xxxhdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png" />
        <resource-file src="www/static/images/android/notification/drawable-mdpi/ic_notification.png" target="app/src/main/res/drawable-mdpi/notification.png" />
        <resource-file src="www/static/images/android/notification/drawable-hdpi/ic_notification.png" target="app/src/main/res/drawable-hdpi/notification.png" />
        <resource-file src="www/static/images/android/notification/drawable-xhdpi/ic_notification.png" target="app/src/main/res/drawable-xhdpi/notification.png" />
        <resource-file src="www/static/images/android/notification/drawable-xxhdpi/ic_notification.png" target="app/src/main/res/drawable-xxhdpi/notification.png" />
        <resource-file src="www/static/images/android/notification/drawable-xxxhdpi/ic_notification.png" target="app/src/main/res/drawable-xxxhdpi/notification.png" />
        <resource-file src="www/static/images/android/status_bar/drawable-mdpi/ic_status_bar.png" target="app/src/main/res/drawable-mdpi/status_bar.png" />
        <resource-file src="www/static/images/android/status_bar/drawable-hdpi/ic_status_bar.png" target="app/src/main/res/drawable-hdpi/status_bar.png" />
        <resource-file src="www/static/images/android/status_bar/drawable-xhdpi/ic_status_bar.png" target="app/src/main/res/drawable-xhdpi/status_bar.png" />
        <resource-file src="www/static/images/android/status_bar/drawable-xxhdpi/ic_status_bar.png" target="app/src/main/res/drawable-xxhdpi/status_bar.png" />
        <resource-file src="www/static/images/android/status_bar/drawable-xxxhdpi/ic_status_bar.png" target="app/src/main/res/drawable-xxxhdpi/status_bar.png" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <preference name="WKWebViewOnly" value="true" />
        <preference name="target-device" value="tablet" />
        <preference name="deployment-target" value="12.1" />
        <preference name="BackupWebStorage" value="none" />
        <preference name="Hostname" value="d2d.unitymedia.de" />
        <preference name="LottieAnimationLocation" value="www/assets/lottie/ios.json" />
        <preference name="SwiftVersion" value="5" />
        <preference name="SplashScreenDelay" value="0"/>
        <preference name="AutoHideSplashScreen" value="true"/>
        <icon height="29" src="www/static/images/appicons/29x29.png" width="29" />
        <icon height="40" src="www/static/images/appicons/40x40.png" width="40" />
        <icon height="50" src="www/static/images/appicons/50x50.png" width="50" />
        <icon height="58" src="www/static/images/appicons/58x58.png" width="58" />
        <icon height="76" src="www/static/images/appicons/76x76.png" width="76" />
        <icon height="80" src="www/static/images/appicons/80x80.png" width="80" />
        <icon height="87" src="www/static/images/appicons/87x87.png" width="87" />
        <icon height="100" src="www/static/images/appicons/100x100.png" width="100" />
        <icon height="120" src="www/static/images/appicons/120x120.png" width="120" />
        <icon height="152" src="www/static/images/appicons/152x152.png" width="152" />
        <icon height="167" src="www/static/images/appicons/167x167.png" width="167" />
        <icon height="180" src="www/static/images/appicons/180x180.png" width="180" />
        <icon height="512" src="www/static/images/appicons/512x512.png" width="512" />
        <icon height="1024" src="www/static/images/appicons/1024x1024.png" width="1024" />
        <icon height="20" src="www/static/images/appicons/20x20.png" width="20" />
        <icon height="57" src="www/static/images/appicons/57x57.png" width="57" />
        <icon height="60" src="www/static/images/appicons/60x60.png" width="60" />
        <icon height="72" src="www/static/images/appicons/72x72.png" width="72" />
        <icon height="114" src="www/static/images/appicons/114x114.png" width="114" />
        <icon height="144" src="www/static/images/appicons/144x144.png" width="144" />
        <splash src="www/static/images/startups/default@2x~universal~anyany.png" />
        <config-file parent="NSLocationWhenInUseUsageDescription" target="*-Info.plist">
            <string>Um zu sehen wo Du Dich aktuell auf der Karte befindest, braucht die D2D-App Zugriff auf Deinen Standort.</string>
        </config-file>
        <config-file parent="NSLocationAlwaysUsageDescription" target="*-Info.plist">
            <string>Um zu sehen wo Du Dich aktuell auf der Karte befindest, braucht die D2D-App Zugriff auf Deinen Standort.</string>
        </config-file>
        <config-file parent="UIRequiresFullScreen" target="*-Info.plist">
            <false />
        </config-file>
        <config-file parent="UIStatusBarHidden" target="*-Info.plist">
            <true />
        </config-file>
        <config-file parent="UIViewControllerBasedStatusBarAppearance" target="*-Info.plist">
            <false />
        </config-file>
    </platform>
</widget>

    package.json:
--- Start of Cordova JSON Snippet ---
{
  "plugins": {
    "@d2d/cordova-plugin-file-transfer": {},
    "@d2d/cordova-plugin-zip": {},
    "cordova-android-support-gradle-release": {
      "ANDROID_SUPPORT_VERSION": "28.+"
    },
    "cordova-open-native-settings": {},
    "cordova-pdf-generator": {},
    "cordova-plugin-androidx-adapter": {},
    "cordova-plugin-app-version": {},
    "cordova-plugin-badge": {},
    "cordova-plugin-calendar": {
      "CALENDAR_USAGE_DESCRIPTION": "Um Wiedervorlagen in Deinem Kalender speichern zu können, benötigt die D2D-App Zugriff darauf.",
      "CONTACTS_USAGE_DESCRIPTION": " "
    },
    "cordova-plugin-delete-launch-screen-cache": {},
    "cordova-plugin-device": {},
    "cordova-plugin-dialogs": {},
    "cordova-plugin-file-opener2": {
      "ANDROID_SUPPORT_V4_VERSION": "28.+"
    },
    "cordova-plugin-file": {},
    "cordova-plugin-file-transfer": {},
    "cordova-plugin-geolocation": {},
    "cordova-plugin-local-notification": {
      "ANDROID_SUPPORT_V4_VERSION": "28.+"
    },
    "cordova-plugin-lottie-splashscreen": {},
    "cordova-plugin-inappbrowser": {},
    "cordova-plugin-ionic": {
      "APP_ID": "0d80246e",
      "CHANNEL_NAME": "production",
      "UPDATE_METHOD": "none",
      "MAX_STORE": "2",
      "UPDATE_API": "https://api.ionicjs.com",
      "MIN_BACKGROUND_DURATION": "30"
    },
    "cordova-plugin-ionic-keyboard": {},
    "cordova-plugin-ionic-webview": {},
    "cordova-plugin-network-information": {},
    "cordova-plugin-pincheck": {},
    "cordova-plugin-screen-orientation": {},
    "cordova-plugin-secure-storage-echo": {},
    "cordova-plugin-statusbar": {},
    "cordova-plugin-whitelist": {},
    "cordova-plugin-x-toast": {},
    "cordova-plugin-zip": {}
  },
  "platforms": [
    "android",
    "ios"
  ]
}
--- End of Cordova JSON Snippet ---
@spillaiveliyam
Copy link

spillaiveliyam commented Oct 11, 2020

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

@timbru31
Copy link
Contributor Author

timbru31 commented Oct 11, 2020

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.

@spillaiveliyam
Copy link

^^ yea thats very much valid. I destroyed it in onFinish .

@ascottk
Copy link

ascottk commented Oct 14, 2020

Hello. Is this fix released? This problem fits the symptoms my users are reporting - and which I can replicate with a simple

Hello World
payload using type: 'base64' . Every second attempt to generate a PDF crashes the entire App. I tried installing 2.2.0 but a.) it didn't solve the problem and b.) the package version is still listed as 2.1.1 - see plugin.xml in pdf-generator-2.2.0.zip\pdf-generator-2.2.0. A fix would let me get my life back ...

@timbru31
Copy link
Contributor Author

You could use our fork as an intermediate solution: https://www.npmjs.com/package/@d2d/cordova-pdf-generator

@ascottk
Copy link

ascottk commented Oct 15, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants