Why is my full-screen web view constantly closing right after opening?

My full-screen video viewing almost always closes immediately after opening, sometimes it works. You can see that the screen blinks in full screen and returns to the original almost every time I press the full-screen button on a YouTube video. What could be the reason for this?

Web browsing is displayed in the tablayout / viewpager settings with some other snippets.

I used this code to show the video: https://github.com/cprcrack/VideoEnabledWebView

And now I use this https://github.com/GoogleChrome/chromium-webview-samples/blob/master/fullscreen-video-sample/app/src/main/java/fullscreenvideosample/android/chrome/google/com/fullscreenvideosample /MainActivity.java

They produce exactly the same behavior.

Logs when the full screen crashes and returns to normal immediately after opening:

07-14 17:41:06.694 D/ ViewRootImpl@33432e1 [GroupActivity]: ViewPostImeInputStage processPointer 0 07-14 17:41:06.786 D/ ViewRootImpl@33432e1 [GroupActivity]: ViewPostImeInputStage processPointer 1 07-14 17:41:06.803 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 07-14 17:41:07.512 D/ ViewRootImpl@33432e1 [GroupActivity]: ViewPostImeInputStage processPointer 0 07-14 17:41:07.592 D/ ViewRootImpl@33432e1 [GroupActivity]: ViewPostImeInputStage processPointer 1 07-14 17:41:07.615 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 07-14 17:41:07.709 V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@3e22579 nm : com.linkhubapp ic=null 07-14 17:41:07.709 I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus 07-14 17:41:07.713 D/InputTransport: Input channel constructed: fd=152 07-14 17:41:07.714 D/InputTransport: Input channel destroyed: fd=159 07-14 17:41:07.714 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 07-14 17:41:07.751 D/ ViewRootImpl@33432e1 [GroupActivity]: Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x1 surface={isValid=true -1176543232} surfaceGenerationChanged=false 07-14 17:41:07.911 D/ ViewRootImpl@33432e1 [GroupActivity]: Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x7 surface={isValid=true -1273339904} surfaceGenerationChanged=true 07-14 17:41:07.921 D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1440x2560]-format:1 07-14 17:41:07.922 D/ ViewRootImpl@33432e1 [GroupActivity]: mHardwareRenderer.updateSurface() mSurface={isValid=true -1273339904} 07-14 17:41:07.974 D/SurfaceView: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,875][1440,1685] result=0x7 surface={Surface(name=null)/@0xb9ffb70 isValid=true -1178691584} 07-14 17:41:08.047 D/SurfaceView: Relayout returned: oldFrame=[0,875][1440,1685] newFrame=[0,875][1440,1685] result=0x5 surface={Surface(name=null)/@0xb9ffb70 isValid=false 0} 07-14 17:41:08.095 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 07-14 17:41:08.163 D/ ViewRootImpl@33432e1 [GroupActivity]: Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x1 surface={isValid=true -1273339904} surfaceGenerationChanged=false 07-14 17:41:08.232 V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@1772e0f nm : com.linkhubapp ic=null 07-14 17:41:08.232 I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus 07-14 17:41:08.233 D/InputTransport: Input channel constructed: fd=173 07-14 17:41:08.233 D/InputTransport: Input channel destroyed: fd=152 

Logs on successful completion of full screen:

 07-14 17:41:27.987 D/ ViewRootImpl@33432e1 [GroupActivity]: ViewPostImeInputStage processPointer 0 07-14 17:41:28.023 D/ ViewRootImpl@33432e1 [GroupActivity]: ViewPostImeInputStage processPointer 1 07-14 17:41:28.048 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 07-14 17:41:28.496 D/ ViewRootImpl@33432e1 [GroupActivity]: ViewPostImeInputStage processPointer 0 07-14 17:41:28.571 D/ ViewRootImpl@33432e1 [GroupActivity]: ViewPostImeInputStage processPointer 1 07-14 17:41:28.616 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 07-14 17:41:28.719 V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@80b2646 nm : com.linkhubapp ic=null 07-14 17:41:28.719 I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus 07-14 17:41:28.725 D/InputTransport: Input channel constructed: fd=155 07-14 17:41:28.725 D/InputTransport: Input channel destroyed: fd=173 07-14 17:41:28.725 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 07-14 17:41:28.766 D/ ViewRootImpl@33432e1 [GroupActivity]: Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x1 surface={isValid=true -1273339904} surfaceGenerationChanged=false 07-14 17:41:28.956 D/ ViewRootImpl@33432e1 [GroupActivity]: Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x1 surface={isValid=true -1273339904} surfaceGenerationChanged=false 07-14 17:41:29.036 D/SurfaceView: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,875][1440,1685] result=0x7 surface={Surface(name=null)/@0xc360d2 isValid=true -1273337856} 07-14 17:41:29.089 D/SurfaceView: Relayout returned: oldFrame=[0,875][1440,1685] newFrame=[0,875][1440,1685] result=0x1 surface={Surface(name=null)/@0xc360d2 isValid=true -1311279104} 

EDIT: It seems to only happen on YouTube. Tested by Vimeo vs youtube. Vimeo opens every time.

+7
android webview fullscreen
source share
3 answers

The best I can think of is that your device is not working. Therefore, I have some suggestions for you.

  • First of all, check it on your device when all its plunger is free and check the result.

  • Secondly, you mentioned that you have a Galaxy S6 and Galaxy S3, run the application on both devices.

  • It is also very useful if you can test your application on another Galaxy S6 and see if it repeats.

After collecting this information, you can find a solution to your problem.

Another thing you can check is to use android:hardwareAccelerated="true" and check if it helps.

+1
source share

This does not answer your question directly, but offers an alternative.

Depending on your use case, it may be appropriate to display the video in the YouTube app instead of the internal WebView. Most Android devices (if not all) have a YouTube app.

 public void playVideo(String key){ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + key)); // Check if the youtube app exists on the device if (intent.resolveActivity(getPackageManager()) == null) { // If the youtube app doesn't exist, then use the browser intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + key)); } else { startActivity(intent); } } 

This will require the user to click "Back" to return to your application later. But this is likely to give the user a better video.

+1
source share

During our discussion with @CantThinkOfAnything, we found the exact problem and came up with a solution. This seems to be an internal issue with Samsung phones. They have their own implementation of WebView, which differs in some details and approaches from Chrome WebView. Before attempting to overcome web browsing issues on Samsung devices (for example, bridging - I mean using a different approach, not web browsing):

  • Refresh Web View
  • See which WebView implementation option you are using Developer options → WebView implementation , here you can switch it

In this case, we only had problems playing videos on YouTube. Therefore, before using the Youtube SDK, you can try to create your own player:

 <iframe width="300" height=".." src="http://www.youtube.com/embed/M68lNfqmTNk" frameborder="0" allowfullscreen></iframe> 

You will need to load this as a separate html into your webview. Such a dirty approach and many disadvantages. You should probably not use this. So, we have finished the decision to use the Youtube SDK, which is much better than iframe. @CantThinkOfAnything - please correct me if I missed something.

PS - in other cases, Samsung webview works great for us.

+1
source share

All Articles