Android 在没有当前上下文的情况下调用OpenGL ES API
当我从显示Google地图的webview切换到另一个视图时,我的应用程序只是偶尔关闭(没有强制关闭对话框,只是关闭)。我在我的日志中得到了这个错误: E/libEGL(29103):在没有当前上下文的情况下调用OpenGL ES API(每个线程记录一次) 有什么想法吗 我有一个main活动,它为每个页面使用不同的“视图”。以下是调用视图的main中的代码:Android 在没有当前上下文的情况下调用OpenGL ES API,android,opengl-es,Android,Opengl Es,当我从显示Google地图的webview切换到另一个视图时,我的应用程序只是偶尔关闭(没有强制关闭对话框,只是关闭)。我在我的日志中得到了这个错误: E/libEGL(29103):在没有当前上下文的情况下调用OpenGL ES API(每个线程记录一次) 有什么想法吗 我有一个main活动,它为每个页面使用不同的“视图”。以下是调用视图的main中的代码: private void changeCardDisplayed(int index) { // Log.i(DEBUG_TA
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));
}
}
更新:
我有一个平板电脑,上面有我的应用程序的预加载版本,当我安装当前代码时,我将此作为崩溃的原因:(如果由于预加载而更改包名,以便可以直接从Eclipse加载,则应用程序不会关闭,这就是我获取OpenGL日志的时候)
01-11 14:54:03.277:I/DEBUG(30128):处理进程崩溃(9)
01-11 14:54:03.277:I/DEBUG(30128):读取tid
01-11 14:54:03.277:I/DEBUG(30128):动臂:pid=30589 uid=10040 gid=10040 tid=30589
01-11 14:54:03.277:I/DEBUG(30128):waitpid:n=30589状态=0000137f
01-11 14:54:03.277:I/DEBUG(30128):已停止--继续
01-11 14:54:03.277:I/DEBUG(30128):waitpid:n=30589状态=00000b7f
01-11 14:54:03.277:I/DEBUG(30128):停止--致命信号
01-11 14:54:03.277:I/DEBUG(30128):***************************************************
01-11 14:54:03.277:I/DEBUG(30128):构建指纹:“华为/MediaPad/hws7300u:3.2/HuaweiMediaPad/C201B021:用户/释放密钥”
01-11 14:54:03.277:I/DEBUG(30128):pid:30589,tid:30589>>com.acuweather.android.tablet这是一个已知的网络视图问题。请注意,此错误不会导致应用程序崩溃。你的问题在别的地方。您在日志中还看到了什么?这是一个已知的WebView问题。请注意,此错误不会导致应用程序崩溃。你的问题在别的地方。您在日志中还看到了什么?OpenGL上下文是线程本地的。看起来您试图在没有上下文的线程中调用某个OpenGL函数。很抱歉这么说。我的应用程序中根本没有使用OpenGL。哦,真不幸。您可能应该发布执行视图切换的代码。我也会遇到同样的错误,尽管在我的例子中,我以本地方式广泛使用OpenGL。很奇怪,您根本不使用OpenGL,却出现了这个错误:(虽然我说不出这种行为的原因,但作为一种解决方法,你可以尝试禁用硬件加速。因为你的崩溃听起来与此相关。OpenGL上下文是线程本地的。看起来你试图在没有上下文的线程中调用某个OpenGL函数。很抱歉,我的应用程序中根本没有使用OpenGL应用程序。哦,不幸的是。您可能应该发布执行视图切换的代码。我也会遇到同样的错误,尽管在我的案例中,我以本机方式大量使用OpenGL。很奇怪,您根本不使用OpenGL,却会出现此错误:(虽然我不知道这种行为的原因,但作为一种解决方法,您可以尝试禁用硬件加速。由于您的碰撞听起来与此相关。它看起来像是驾驶员碰撞,请使用repu步骤和完整日志在上提交一个错误。还请指出您正在使用的设备。感谢Romain Guy…我提交了,它看起来像一个dr。)iver crash,请用复制步骤和完整日志在上提交一个bug。还请说明您正在使用的设备。谢谢Romain Guy…我提交了,它是
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}