0

I'm create a Android Application to show a webpage. When install app in mobile device, the first time run fast.If I click a Button in webpage, charging is fired at moment. But when close app add relaunch, the WebView becomes slow. It takes more time to load and buttons are lag.

I discovered that deleting the folder app_webview on application folder and relaunch application, app run fast. If I closed app and relaunch, app is slow again.

What is the reason for this slowdown? Is it possible to solve it?

This is my config:

    mWebView.setListener(this, this);
    mWebView.setInitialScale(0);
    mWebView.setVerticalScrollBarEnabled(true);
    mWebView.setGeolocationEnabled(true);
    mWebView.setMixedContentAllowed(true);
    mWebView.setCookiesEnabled(true);
    mWebView.setThirdPartyCookiesEnabled(true);
    mWebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG);
    mWebView.addJavascriptInterface(new JavaBridge(this, mWebView), "JavaBridge");
    mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageFinished(WebView view, String url) {
            String cookies = CookieManager.getInstance().getCookie(url);
            Log.d("COOKIE", "All the cookies in a string:" + cookies);
        }

    });

    mWebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);

    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
    mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    mWebView.getSettings().setAppCacheEnabled(false);

    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onReceivedTitle(WebView view, String title) {
            super.onReceivedTitle(view, title);
            //Toast.makeText(MainActivity.this, title, Toast.LENGTH_SHORT).show();
        }

    });

    mWebView.addHttpHeader("X-Requested-With", "");

    mWebView.loadUrl(url);

Thanks a lot!! Regards

pablogupi
  • 774
  • 11
  • 27
  • Try this link :- https://stackoverflow.com/questions/55842151/problem-when-load-html5-videos-into-webview/55844152#55844152 If it does not solve your problem, reply here again. – Ankit Gupta Apr 25 '19 at 11:01
  • I just discovered that the app_webview / variations_seed_new file is causing bad performance. If I delete it, the application works fast. What will be the problem? – pablogupi Apr 25 '19 at 11:37
  • how are u deleting and generating the variations_seed_new file ?? – Ankit Gupta Apr 25 '19 at 11:53
  • I have been deleting the files in the app_webview folder one by one and launching the app. I discovered that the problem was variations_seed and variations_seed_new. If I delete them, they create themselves when launching the app. Every time I launch the app I delete them and it always works fast. But I do not know why with these files the application is slower. – pablogupi Apr 25 '19 at 13:41
  • I just want to know why are they being generated so that i can look for actual problem.When i used webview they are not deleted at any time.What is purpose of both files in your code ?? If there is a memory issue after including them ,try multidex and dexOptions { javaMaxHeapSize "4g" } – Ankit Gupta Apr 25 '19 at 13:54
  • I also want to know why these files go slower. I have researched and I have not found anything. Throughout the day I will test the multidex and the dexOptions. Thank you – pablogupi Apr 25 '19 at 13:59
  • Multidex and dexOptions {javaMaxHeapSize "4g"} are not the solution. Without deleting the files the application is still slow. If I eliminate them, go back fast – pablogupi Apr 25 '19 at 14:16
  • I can't understand why this file :- variations_seed_new are used in your app and how are u deleting it (proper step) .Without this , i can't tell you exact cause of problem – Ankit Gupta Apr 26 '19 at 05:09

0 Answers0