2012-01-11 105 views
1

当我从显示Google地图的webview切换到另一个视图时,我的应用程序仅关闭(不强制关闭对话框,简单地关闭)。我得到这个错误在我的logcat:在没有当前上下文的情况下调用OpenGL ES API

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

任何想法?

我有一个mainActivity为每个页面使用不同的“视图”。下面是从一个视图调用主代码:

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()); 
    } 
} 

这里被加载的地图在该视图MapsView.java所述的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)); 

     } 

    } 

UPDATE:


我有我的应用程序的预加载版本的平板电脑,当我安装我的当前代码时,我得到这个作为我的原因崩溃:(如果我更改包名称由于预加载,以便我可以加载它直接从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} 
+0

OpenGL上下文是线程本地的。看起来像你试图调用一些OpenGL函数,而没有在没有上下文的线程中。对不起,说明明显。 – pmr 2012-01-11 17:49:55

+0

我在应用程序中根本没有使用OpenGL。 – taraloca 2012-01-11 17:55:48

+0

哦,不幸的。您可能应该发布视图切换的代码。 – pmr 2012-01-11 18:03:37

回答

5

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

+0

我添加了一个编辑到我原来​​的包括logcat – taraloca 2012-01-11 19:59:11

+0

它看起来像一个驱动程序崩溃,请提交一个bug在http://b.android.com有repro步骤和完整的日志。还请指出你正在使用什么设备。 – 2012-01-11 20:00:37

+1

谢谢Romain Guy ...我提交了,它是[Issue 24232](http:// code。 google.com/p/android/issues/detail?id=24232&thanks=24232&ts=1326314626) – taraloca 2012-01-11 20:45:57

相关问题