【问题标题】:HTML5-Video crashes with "Surface Texture is abondoned" in WebviewHTML5 视频在 Webview 中因“表面纹理被放弃”而崩溃
【发布时间】:2015-02-16 09:11:02
【问题描述】:

我在 Android Studio 中创建了一个 webview,并启用了 WebChromeClient 和硬件加速以在自定义播放列表中播放 HTML5 视频。

几天来一切正常,但是当我离开活动时,即打开第二个活动,然后返回网络视图,大部分视频会在一段时间后崩溃。声音继续,但屏幕变黑。

同时logcat返回“E/SurfaceTexture:[unnamed-6010-15498] updateTexImage: SurfaceTexture is废弃!”。

我现在的问题是:这是硬件问题吗?如果是,为什么在我第一次启动 webview 时没有出现?

AndroidManifest.xml:

<application
  android:name=".App"
  android:allowBackup="true"
  android:hardwareAccelerated="true"
  android:icon="@drawable/ic_launcher"
  android:label="@string/General_Appinfo_Label"
  android:theme="@style/AppTheme" >

<activity
  android:name=".Webview"
  android:configChanges="orientation|screenSize"
  android:label="@string/General_Appinfo_Label"
  android:noHistory="true"
  android:hardwareAccelerated="true"
  android:theme="@android:style/Theme.NoTitleBar" >
  <intent-filter>
   <action android:name="de.neolino.smartesign.Webview" />
   <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
</activity>

Webview.class(摘录):

Window window = this.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
window.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
App.webview = new WebView(this);
WebChromeClient chromeClient = new WebChromeClient();
App.webview.setWebChromeClient(chromeClient);
windowContext = getWindow(); // for later use
decorViewWebview = windowContext.getDecorView();
final int uiOptions =(View.SYSTEM_UI_FLAG_FULLSCREEN
                     | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                     | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                     | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                     | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                     | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
decorViewWebview.setSystemUiVisibility(uiOptions);
WebSettings webSettings = App.webview.getSettings();
webSettings.setAppCacheEnabled(false);
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
App.webview.clearCache(true);
webSettings.setAllowFileAccess(true);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setSaveFormData(true);
setContentView(App.webview);    
webSettings.setMediaPlaybackRequiresUserGesture(false);
webSettings.setJavaScriptEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
App.webview.loadUrl(Pref.getString("SettingsWebviewTargetDialog"));

Logcat:

02-16 10:02:50.707    2678-9854/? I/OMXPlayer﹕ Stop Player.
02-16 10:02:50.757    2678-9854/? I/vpu-lib﹕ <gpu> free handle: 0x4c932b78, paddr: 0x4762b000, vaddr: 0x44f01000
02-16 10:02:50.757    2678-9854/? I/vpu-lib﹕ <gpu> free handle: 0x4c932b50, paddr: 0x48210000, vaddr: 0x45ae6000
02-16 10:02:50.757    2678-9854/? I/vpu-lib﹕ <gpu> free handle: 0x4c93da30, paddr: 0x48710000, vaddr: 0x45fe6000
02-16 10:02:50.777    2678-2939/? I/OMXPlayer﹕ Loading content: sharedfd://24:0:27399381:0
02-16 10:02:50.777    2678-2939/? I/OMXPlayer﹕ LEVEL: 1 FUNCTION: MediaTypeInspect LINE: 1656
02-16 10:02:50.777    2678-2939/? I/OMXPlayer﹕ Can't inspect media content type by subfix.
02-16 10:02:50.807   2678-20974/? I/OMXPlayer﹕ LEVEL: 1 FUNCTION: prepare LINE: 422
02-16 10:02:50.807   2678-20974/? I/OMXPlayer﹕ failed to open file: /data/system/audio_pass_through_pref.
02-16 10:02:50.807   2678-20974/? I/OMXPlayer﹕ Can't open library: lib_aacplusd_wrap_arm12_elinux_android.so
02-16 10:02:50.807   2678-20974/? I/OMXPlayer﹕ Cannot load library: load_library(linker.cpp:745): library "lib_aacplusd_wrap_arm12_elinux_android.so" not found
02-16 10:02:50.807    6010-6010/de.neolino.smartesign E/SurfaceTexture﹕ [unnamed-6010-15654] updateTexImage: SurfaceTexture is abandoned!
02-16 10:02:50.837   2678-20974/? I/vpu-lib﹕ Product Info: i.MX6Q/D/S
02-16 10:02:50.847   2678-20974/? I/OMXPlayer﹕ VideoRender role: video_render.surface
02-16 10:02:50.847   2678-20975/? I/OMXPlayer﹕ nPreCacheSize = 913312
02-16 10:02:50.877   2678-20974/? I/vpu-lib﹕ <gpu> alloc handle: 0x4c15fdf0, paddr: 0x47232000, vaddr: 0x44b08000
02-16 10:02:50.887   2678-20974/? I/vpu-lib﹕ <gpu> alloc handle: 0x4c15fe68, paddr: 0x47385000, vaddr: 0x44c5b000
02-16 10:02:50.887   2678-20974/? I/vpu-lib﹕ <gpu> alloc handle: 0x4c15ff10, paddr: 0x474d8000, vaddr: 0x44dae000
02-16 10:02:50.887   2678-20978/? I/vpu-lib﹕ <gpu> alloc handle: 0x4c15ff68, paddr: 0x48210000, vaddr: 0x45ae6000
02-16 10:02:50.887   2678-20978/? I/vpu-lib﹕ <gpu> alloc handle: 0x4c15ff90, paddr: 0x4762b000, vaddr: 0x44f01000
02-16 10:02:50.887   2678-20978/? I/vpu-lib﹕ bitstreamMode 1, chromaInterleave 1, mapType 0, tiled2LinearEnable 0
02-16 10:02:50.887   2678-20978/? W/vpu-lib﹕ VPU iram is less than needed, some parts don't use iram
02-16 10:02:50.897   2678-20974/? I/vpu-lib﹕ <gpu> free handle: 0x4c15fdf0, paddr: 0x47232000, vaddr: 0x44b08000
02-16 10:02:50.897   2678-20974/? I/vpu-lib﹕ <gpu> free handle: 0x4c15fe68, paddr: 0x47385000, vaddr: 0x44c5b000
02-16 10:02:50.897   2678-20974/? I/vpu-lib﹕ <gpu> free handle: 0x4c15ff10, paddr: 0x474d8000, vaddr: 0x44dae000
02-16 10:02:50.927   2678-20978/? I/vpu-lib﹕ <gpu> alloc handle: 0x4c768570, paddr: 0x48710000, vaddr: 0x45fe6000
02-16 10:02:50.927   2678-20974/? I/OMXPlayer﹕ Seek to 0
02-16 10:02:50.947    2678-9855/? I/OMXPlayer﹕ start player.

【问题讨论】:

    标签: android html video webview


    【解决方案1】:

    在我的情况下,解决方案是时间问题。

    我在后台使用 IntentService 更改了本地数据。之后,我关闭了 Webview 并再次启动它。但表面纹理似乎没有足够快地意识到这一点,或者根本没有重建。

    一个简单的webview.reload() resp。 webview.loadUrl() 在启动 Webview 的新实例的情况下可以解决问题。

    从 Android 4.4 开始,您必须在运行 Webview 的同一线程中执行此操作。要从 Webview 的线程外部执行此操作 - 即一个函数 - 您必须构建一个全局 Webview 对象并像这样调用它:

    App.webview.post(new Runnable() {
        @Override
        public void run() {
          App.webview.loadUrl("file://" + someLocalFile.getAbsolutePath());
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2014-10-24
      • 1970-01-01
      • 1970-01-01
      • 2021-05-30
      • 2016-06-06
      • 2013-07-27
      • 2013-03-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多