1

The application consists of a simple splash screen and webview. But when it comes to the webview side, there is a problem of freezing in the application. It doesn't work exactly when I scroll. There is no freeze in the normal browser. What is the problem

Splash Screen


    @Override
    protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash_screen);

        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent(SplashScreen.this,MainActivity.class));
                finish();
            }

        }, 1200);



    }
}

This is Main activity Main Activity


   private final static int FCR = 1;
   WebView webView;
   private String mCM;
   private ValueCallback<Uri> mUploadMessage;
   public ValueCallback<Uri[]> uploadMessage;
   public static final int REQUEST_SELECT_FILE = 100;
   private final static int FILECHOOSER_RESULTCODE = 1;

   @SuppressLint("WrongViewCast")
   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);

       webView = findViewById(R.id.webView);
       webView.loadUrl("https://dokuzlama.com");
       WebSettings webSettings = webView.getSettings();
       webSettings.setJavaScriptEnabled(true);
       webSettings.setSupportZoom(false);
       webSettings.setAllowFileAccess(true);
       webSettings.setAllowFileAccess(true);
       webSettings.setAllowContentAccess(true);

       webView.setWebViewClient(new Callback());
       webView.setWebChromeClient(new WebChromeClient()
       {
           // For 3.0+ Devices (Start)
           // onActivityResult attached before constructor
           protected void openFileChooser(ValueCallback uploadMsg, String acceptType)
           {
               mUploadMessage = uploadMsg;
               Intent i = new Intent(Intent.ACTION_GET_CONTENT);
               i.addCategory(Intent.CATEGORY_OPENABLE);
               i.setType("image/*");
               startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE);
           }


           // For Lollipop 5.0+ Devices
           public boolean onShowFileChooser(WebView mWebView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
           {
               if (uploadMessage != null) {
                   uploadMessage.onReceiveValue(null);
                   uploadMessage = null;
               }

               uploadMessage = filePathCallback;

               Intent intent = fileChooserParams.createIntent();
               try
               {
                   startActivityForResult(intent, REQUEST_SELECT_FILE);
               } catch (ActivityNotFoundException e)
               {
                   uploadMessage = null;
                   Toast.makeText(MainActivity.this.getApplicationContext(), "Cannot Open File Chooser", Toast.LENGTH_LONG).show();
                   //eski---- >   Toast.makeText(getActivity().getApplicationContext(), "Cannot Open File Chooser", Toast.LENGTH_LONG).show();
                   return false;
               }
               return true;
           }

           //For Android 4.1 only
           protected void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
           {
               mUploadMessage = uploadMsg;
               Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
               intent.addCategory(Intent.CATEGORY_OPENABLE);
               intent.setType("image/*");
               startActivityForResult(Intent.createChooser(intent, "File Browser"), FILECHOOSER_RESULTCODE);
           }

           protected void openFileChooser(ValueCallback<Uri> uploadMsg)
           {
               mUploadMessage = uploadMsg;
               Intent i = new Intent(Intent.ACTION_GET_CONTENT);
               i.addCategory(Intent.CATEGORY_OPENABLE);
               i.setType("image/*");
               startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
           }
       });
   }

   public class Callback extends WebViewClient {
       public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
           Toast.makeText(getApplicationContext(), "Uygulama yüklenemedi", Toast.LENGTH_SHORT).show();
       }
   }

   @Override
   public void onActivityResult(int requestCode, int resultCode, Intent intent) {
       super.onActivityResult(requestCode, resultCode, intent);
       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
           if (requestCode == REQUEST_SELECT_FILE) {
               if (uploadMessage == null)
                   return;
               uploadMessage.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
               uploadMessage = null;
           }
       } else if (requestCode == FILECHOOSER_RESULTCODE) {
           if (null == mUploadMessage)
               return;
           // Use MainActivity.RESULT_OK if you're implementing WebView inside Fragment
           // Use RESULT_OK only if you're implementing WebView inside an Activity
           Uri result = intent == null || resultCode != MainActivity.RESULT_OK ? null : intent.getData();
           mUploadMessage.onReceiveValue(result);
           mUploadMessage = null;
       } else
           Toast.makeText(MainActivity.this.getApplicationContext(), "Failed to Upload Image", Toast.LENGTH_LONG).show();
       //eski____ Toast.makeText(getActivity().getApplicationContext(), "Failed to Upload Image", Toast.LENGTH_LONG).show();
   }

   @Override
   public void onBackPressed() {
       if (webView.canGoBack()){
           webView.goBack();
       } else {
           super.onBackPressed();
       }
   }
}

Logcat view

05-18 19:38:45.529 4306-4306/? E/libprocessgroup: failed to make and chown /acct/uid_10059: Read-only file system
05-18 19:38:45.555 4306-4314/? E/art: Failed sending reply to debugger: Broken pipe
05-18 19:38:47.146 4306-4348/com.dokuzlama.dokuzlama E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
05-18 19:38:47.171 4306-4348/com.dokuzlama.dokuzlama E/chromium: [ERROR:gl_surface_egl.cc(411)] eglChooseConfig failed with error EGL_SUCCESS
05-18 19:38:47.221 4306-4348/com.dokuzlama.dokuzlama E/chromium: [ERROR:gl_surface_egl.cc(411)] eglChooseConfig failed with error EGL_SUCCESS
05-18 19:38:49.485 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:49.486 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:49.541 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:49.542 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:49.923 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:49.924 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:50.003 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:50.004 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw

I researched and analyzed a lot but I couldn't find. The app is working. But I think It's not stabile.

  • Do you see anything suspicious in the logcat? The best way of debugging such problems are looking into the logcat and search for the error logs if there is any. – Reaz Murshed May 18 '20 at 19:34
  • I'm a little novice. I also added the logcat output, can you look? – Bahadırlı May 18 '20 at 19:41
  • it just doesn't work on android 6.0. Its error is "Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth ()' on a null object reference". But it works in other versions (android 5, 5.1, 7.0, 7.1, 8.0, 9.0, 10.0), it just contracts and navigating the page is a nuisance. The scroll function is like torture. – Bahadırlı May 18 '20 at 19:42
  • It looks like a problem with the chrome driver that is mentioned here in this question - https://stackoverflow.com/questions/57985765/android-9-webview-also-admob-ads-not-loading-after-chrome-update – Reaz Murshed May 18 '20 at 19:44
  • Have you set a background or something like that to the scrollview? You might want to turn hardwareacceleration off for activitymain. To turn off hardwareacceleration go to android manifest and add this – Aditya Kurkure May 18 '20 at 19:54
  • Thanks @AdityaKurkure **android:hardwareAccelerated="false"** didn't work but **android:hardwareAccelerated="true"** is working good – Bahadırlı May 18 '20 at 20:31

1 Answers1

2

I solved problem. android: hardwareAccelerated = I added the "true" manifest file and the problem with it has been removed.

<activity
            android:name=".MainActivity"
            android:hardwareAccelerated="true">
        </activity>