android - 在没有当前上下文的情况下调用 OpenGL ES API

标签 android opengl-es

当我从显示谷歌地图的 WebView 切换到另一个 View 时,我的应用程序只会偶尔关闭(没有强制关闭对话框,只是关闭)。我的 logcat 中出现此错误:

E/libEGL(29103):在没有当前上下文的情况下调用 OpenGL ES API(每个线程记录一次)

有什么想法吗?

我有一个 mainActivity,它为每个页面使用不同的“ View ”。以下是调用 View 的主要代码:

private void changeCardDisplayed(int index) {
//      Log.i(DEBUG_TAG, "changeCardDisplay index is " + index);
        if (mCardLayout != null){
            mCardLayout.destroy();
        } else {
            mCardLayout = new CardLayout(this);
        }
        if (mMapView != null) mMapView.destroy();
        mCardLayout = null;
        mMapView = null;
        mCardContainer.removeAllViews();
        mMapsContainer.removeAllViews();
        if (mWD != null) {
            mAdView.makeAdRequest(mWD.cityId, mWD.iconCode);
        }
        System.gc();
        switch (index) {
        case ACCUWX.Views.CURRENT_VIEW:
            mCardLayout = new CurrentView(this);
            break;
        case ACCUWX.Views.FORECAST_VIEW:
            mCardLayout = new ForecastView(this);
            break;
        case ACCUWX.Views.HOURLY_VIEW:
            mCardLayout = new HourlyListView(this);
            break;
        case ACCUWX.Views.LIFESTYLE_VIEW:
            mCardLayout = new LifestyleView(this);
            break;
        case ACCUWX.Views.VIDEO_VIEW:
            mCardLayout = new VideoView(this);
            break;
        case ACCUWX.Views.NEWS_VIEW:
            mCardLayout = new NewsView(this);
            break;
        case ACCUWX.Views.MAP_VIEW:
            mMapView = new MapsView(this);
            break;
        default: mCardLayout = new CurrentView(this);
            break;
        }
        if (index == ACCUWX.Views.MAP_VIEW) {
            mMapsContainer.addView(mMapView);
        } else {
            mCardContainer.addView(mCardLayout);
        }
    }

这是 CardLayout 类:

public class CardLayout extends RelativeLayout {

    //XXX Constants
    private static final String DEBUG_TAG = "Tablet/CardLayout";

    public CardLayout(Context context, AttributeSet attrs) {
        super(context, attrs);

    }
    public CardLayout(Context context) {
        super(context);

    }
    /**
     * Updates layout display with the provided WeatherData
     * @param wdm
     */
    public void update(WeatherData wd) {}
    /**
     * Tell the view to do any final cleanup
     */
    public void destroy(){ 
//      Log.i(DEBUG_TAG, "destroy");
//      this.removeAllViews();
    }

    public int getViewType() {
        return ACCUWX.CardViewTypes.get(this.getClass()) == null ? -999 : ACCUWX.CardViewTypes.get(this.getClass());
    }
}

这是在此 View MapsView.java 中加载 map 的 updateView 方法:

    private void updateView(){
        mWebView = (WebView)findViewById(R.id.mapWebView);
        mWebView.setFocusable(false); 
        mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        Double lat = 0.0;
        Double lon = 0.0;
        lat = Double.parseDouble(mWd.getCurrentWeatherDataModel().lat);
        lon = Double.parseDouble(mWd.getCurrentWeatherDataModel().lon);
        mCenterURL = "javascript:mpSetCenter(" + lat + "," + lon + ")";


        if (WeatherData.isWaking()) WeatherData.setWakingInMaps(true);

//      Log.i(DEBUG_TAG, "centerURL is " + mCenterURL);
        if (mWebView != null) {
            mWebView.getSettings().setEnableSmoothTransition(true);
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.setWebViewClient(new WebViewClient() {
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    String GOOGLE = "http://maps.google.com/maps?ll=" + mWd.getCurrentWeatherDataModel().lat + "," + mWd.getCurrentWeatherDataModel().lon +"&z=7&t=m";
                    URL urlObj;
                    try {
                        urlObj = new URL(url);
                        if(!(TextUtils.equals(urlObj.toString(), TERMS_OF_USE) || TextUtils.equals(urlObj.toString(), GOOGLE))){
                            return false;
                        } else if(TextUtils.equals(urlObj.toString(), GOOGLE)) {
                            return true;
                        }else if (TextUtils.equals(urlObj.toString(), TERMS_OF_USE)) {
                            // Open it in phone's browser rather than app's webview
                            if (mListener!=null) 
                                mListener.showMapsTermsOfUse(TERMS_OF_USE);
                            return true;
                        } 

                    } catch (MalformedURLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    return false;
                } 

                @Override
                public void onPageFinished(WebView view, String url) {
//                  Log.i(DEBUG_TAG, "onPageFinished() b4 dimiss dialogs");
                    Dialogs.dismiss();
                    mHandler.removeCallbacks(mRunnable);
                    mHandler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            if(mWebView != null) {
//                              Log.i(DEBUG_TAG, "run() onPageFinished");
                                mWebView.loadUrl(mCenterURL);
                                if(Utilities.isTv(mContext)) {
                                    mWebView.loadUrl("javascript:hideMarker()");
                                }
                            }
                        }
                    }, 1000); 


                    init();
                    WeatherData.setWakingInMaps(false);
                }

                @Override
                public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
//                  Log.i(DEBUG_TAG, "Error, oh noes! " + description);
                }
            });
            mWebView.setWebChromeClient(new WebChromeClient() {
                 @Override
                    public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
//                   Log.i(DEBUG_TAG, "message in onJsAlert is " + message);
                        result.confirm();
                        return true;
                    }
            });

            if (Utilities.isTv(mContext)) {
                mZoomControl = (ZoomControl) findViewById(R.id.zoom_control);
                mZoomControl.setVisibility(View.VISIBLE);
                mZoomControl.setOnZoomListener(mZoomListener);
                mPanningControl = (PanningControl) findViewById(R.id.panning_control);
                mPanningControl.setVisibility(View.VISIBLE);
                mPanningControl.setPanningListener(mPanningListener);
            }

            String roundedTime = Utilities.roundMinutes(5);
            String url = "http://vortex.accuweather.com/widget/googleMaps/maps_v3_honeycomb.html?cbt=" + roundedTime;
            mWebView.loadUrl(url);
//          mWebView.loadUrl("file:///android_asset/maps_v3_honeycomb.html"); 
            Dialogs.dismiss();
//          Log.i(DEBUG_TAG, "dismiss b4 this stmnt and showLoadingDialog after");
            Dialogs.showLoadingDialog((android.app.Activity) mContext);
            mHandler.postDelayed(mRunnable, 30000); 

            consumeKeyEvent(this.findViewById(R.id.mapLayout));

        }

    }

更新:


我有一个预装了我的应用程序版本的平板电脑,当我将当前代码安装到上面时,我将此作为崩溃的原因:(如果我由于预装而更改了包名称,以便我可以直接从Eclipse,应用程序没有关闭,那是我收到 OpenGL 日志的时候)

01-11 14:54:03.277: I/DEBUG(30128): handle_crashing_process(9)
01-11 14:54:03.277: I/DEBUG(30128): reading tid
01-11 14:54:03.277: I/DEBUG(30128): BOOM: pid=30589 uid=10040 gid=10040 tid=30589
01-11 14:54:03.277: I/DEBUG(30128): waitpid: n=30589 status=0000137f
01-11 14:54:03.277: I/DEBUG(30128): stopped -- continuing
01-11 14:54:03.277: I/DEBUG(30128): waitpid: n=30589 status=00000b7f
01-11 14:54:03.277: I/DEBUG(30128): stopped -- fatal signal
01-11 14:54:03.277: I/DEBUG(30128): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-11 14:54:03.277: I/DEBUG(30128): Build fingerprint: 'Huawei/MediaPad/hws7300u:3.2/HuaweiMediaPad/C201B021:user/release-keys'
01-11 14:54:03.277: I/DEBUG(30128): pid: 30589, tid: 30589  >>> com.accuweather.android.tablet <<<
01-11 14:54:03.277: I/DEBUG(30128): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 000073dc
01-11 14:54:03.277: I/DEBUG(30128):  r0 00dfae78  r1 000073dc  r2 00000060  r3 00000001
01-11 14:54:03.277: I/DEBUG(30128):  r4 00dfae78  r5 00000042  r6 00207a34  r7 00000060
01-11 14:54:03.277: I/DEBUG(30128):  r8 0000004b  r9 000073dc  10 00000060  fp 00000001
01-11 14:54:03.277: I/DEBUG(30128):  ip 00000003  sp bec4dfd4  lr 8288bec1  pc aff0c9e8  cpsr 80000010
01-11 14:54:03.277: I/DEBUG(30128):  d0  0000a0000000a000  d1  000001c0000001a8
01-11 14:54:03.277: I/DEBUG(30128):  d2  0000100000000006  d3  0000204000000002
01-11 14:54:03.277: I/DEBUG(30128):  d4  000000000000000f  d5  0000000000000000
01-11 14:54:03.277: I/DEBUG(30128):  d6  00000000000000ff  d7  0000000000000000
01-11 14:54:03.277: I/DEBUG(30128):  d8  0000000000000000  d9  430b000041200000
01-11 14:54:03.277: I/DEBUG(30128):  d10 3f0000003ea655c4  d11 0000004040800000
01-11 14:54:03.277: I/DEBUG(30128):  d12 00000000000000c5  d13 0000000000000000
01-11 14:54:03.277: I/DEBUG(30128):  d14 0000000000000000  d15 0000000000000000
01-11 14:54:03.277: I/DEBUG(30128):  d16 43c8000000000000  d17 c418000043c80400
01-11 14:54:03.277: I/DEBUG(30128):  d18 3efffee044180200  d19 40b794363efffee0
01-11 14:54:03.277: I/DEBUG(30128):  d20 4113d70a3f800000  d21 007007983f800000
01-11 14:54:03.277: I/DEBUG(30128):  d22 00000c0707010701  d23 0009000000000000
01-11 14:54:03.277: I/DEBUG(30128):  d24 0000000000000000  d25 3ff0000000000000
01-11 14:54:03.277: I/DEBUG(30128):  d26 0000000000000000  d27 3ff0000000000000
01-11 14:54:03.277: I/DEBUG(30128):  d28 3ff2fe0de7600000  d29 0000000000000000
01-11 14:54:03.277: I/DEBUG(30128):  d30 3ff0000000000000  d31 0000000000000000
01-11 14:54:03.277: I/DEBUG(30128):  scr 8000001b
01-11 14:54:03.387: I/DEBUG(30128):          #00  pc 0000c9e8  /system/lib/libc.so
01-11 14:54:03.387: I/DEBUG(30128):          #01  lr 8288bec1  /system/lib/egl/libGLESv2_adreno200.so
01-11 14:54:03.387: I/DEBUG(30128): libc base address: aff00000
01-11 14:54:03.387: I/DEBUG(30128): code around pc:
01-11 14:54:03.387: I/DEBUG(30128): aff0c9c8 f440428d 1afffff5 e212207f 0a00001e 
01-11 14:54:03.387: I/DEBUG(30128): aff0c9d8 e3520020 ba000007 e320f000 e1a0c2a2 
01-11 14:54:03.387: I/DEBUG(30128): aff0c9e8 f421028d e25cc001 f400028d 1afffffb 
01-11 14:54:03.387: I/DEBUG(30128): aff0c9f8 e212201f 0a000014 e2522010 ba000002 
01-11 14:54:03.387: I/DEBUG(30128): aff0ca08 f4610a8d f4400a8d 0a00000f e1b0ce82 
01-11 14:54:03.387: I/DEBUG(30128): code around lr:
01-11 14:54:03.387: I/DEBUG(30128): 8288bea0 f505fb01 18111e6a f507fa51 f707fa15 
01-11 14:54:03.387: I/DEBUG(30128): 8288beb0 e0082500 46494620 35019a0b edeef7d2 
01-11 14:54:03.387: I/DEBUG(30128): 8288bec0 19e49a0c 45454491 e0eadbf4 00a92301 
01-11 14:54:03.387: I/DEBUG(30128): 8288bed0 fa131e4a 1811f007 f307fa51 f007fa13 
01-11 14:54:03.387: I/DEBUG(30128): 8288bee0 980b900f ede6f7d2 28004607 80d6f000 
01-11 14:54:03.387: I/DEBUG(30128): stack:
01-11 14:54:03.387: I/DEBUG(30128):     bec4df94  00000000  
01-11 14:54:03.387: I/DEBUG(30128):     bec4df98  00000043  
01-11 14:54:03.387: I/DEBUG(30128):     bec4df9c  00214a08  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfa0  82876009  /system/lib/egl/libGLESv2_adreno200.so
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfa4  00207a34  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfa8  00000000  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfac  0000004b  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfb0  00000004  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfb4  00000009  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfb8  00000001  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfbc  82889053  /system/lib/egl/libGLESv2_adreno200.so
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfc0  00000001  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfc4  00000004  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfc8  df002777  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfcc  e3a070ad  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfd0  00000018  
01-11 14:54:03.387: I/DEBUG(30128): #00 bec4dfd4  00dfae78  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfd8  00000000  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfdc  00000009  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfe0  00dfb570  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfe4  000000d7  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfe8  00000475  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dfec  aff135e3  /system/lib/libc.so
01-11 14:54:03.387: I/DEBUG(30128):     bec4dff0  00000000  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dff4  00000004  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dff8  002ea397  
01-11 14:54:03.387: I/DEBUG(30128):     bec4dffc  00000000  
01-11 14:54:03.387: I/DEBUG(30128):     bec4e000  00000000  
01-11 14:54:03.387: I/DEBUG(30128):     bec4e004  00000060  
01-11 14:54:03.387: I/DEBUG(30128):     bec4e008  fffff380  
01-11 14:54:03.387: I/DEBUG(30128):     bec4e00c  00001c20  
01-11 14:54:03.387: I/DEBUG(30128):     bec4e010  00000320  
01-11 14:54:03.387: I/DEBUG(30128):     bec4e014  00000018  
01-11 14:54:03.387: I/DEBUG(30128):     bec4e018  009043fc  
01-11 14:54:04.897: I/BootReceiver(23874): Copying /data/tombstones/tombstone_07 to DropBox (SYSTEM_TOMBSTONE)
01-11 14:54:04.907: I/DEBUG(30128): detaching
01-11 14:54:04.907: I/DEBUG(30128): debuggerd committing suicide to free the zombie!
01-11 14:54:04.917: I/DEBUG(30857): debuggerd: Sep 11 2011 00:30:27
01-11 14:54:04.977: E/InputDispatcher(23874): channel '41764b18 com.accuweather.android.tablet/com.accuweather.android.tablet.Main (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
01-11 14:54:04.977: E/InputDispatcher(23874): channel '41764b18 com.accuweather.android.tablet/com.accuweather.android.tablet.Main (server)' ~ Channel is unrecoverably broken and will be disposed!
01-11 14:54:04.987: I/WindowManager(23874): WIN DEATH: Window{41764b18 com.accuweather.android.tablet/com.accuweather.android.tablet.Main paused=false}
01-11 14:54:04.997: I/ActivityManager(23874): Process com.accuweather.android.tablet (pid 30589) has died.
01-11 14:54:04.997: I/WindowManager(23874): WINDOW DIED Window{41764b18 com.accuweather.android.tablet/com.accuweather.android.tablet.Main paused=false}

最佳答案

这是一个已知的 WebView 问题。我们正在努力:) 请注意,此错误不会导致应用程序崩溃。你的问题出在别处。您在日志中还看到了什么?

关于android - 在没有当前上下文的情况下调用 OpenGL ES API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8824082/

相关文章:

android - 带有 ADT 的 Eclipse - adb.exe 即使在 IDE 退出后仍继续运行

android - 在 Android Studio 中使用预建库

android - 如何远程唤醒手机?

Android NDK - 构建 TessTwo(Android 版 Tesseract 工具的分支) - ndk-build 失败

android - 寻找适用于 iOS 和 Android 的基本 2D/3D 图形的跨平台方法

java - 布局更改时的 fragment 管理

java - 在 libgdx 中将纹理分割成拼图

iPhone截图从后台返回全白

c++ - 恢复 OpenGL 状态

opengl - 获取支持的 GLSL 版本