bbenchild 2014-09-30 09:27
浏览 3473

android.net.nsd 发现服务时随机重启报错 dequeueBuffer failed

小弟最近在做安卓的开发,用了android.net.nsd的服务注册与发现。在模拟器上调试的时候没有发现任何问题。但是将demo放到智能电视的时候出了问题。程序有时正常有时会重启。进过不断的调试发现是在启动NSD服务发现的时候报错了。

报错信息如下:
09-30 15:10:56.760: I/sg_life(11572): start discover……
09-30 15:10:56.760: V/ActivityThread(11572): Resume ActivityRecord{41664cf8 token=android.os.BinderProxy@41664490 {com.example.testapk/com.example.testapk.ui.MDEActivity}} started activity: false, hideForNow: false, finished: false
09-30 15:10:56.768: V/ActivityThread(11572): Scheduling idle handler for ActivityRecord{41664cf8 token=android.os.BinderProxy@41664490 {com.example.testapk/com.example.testapk.ui.MDEActivity}}
09-30 15:10:56.856: E/SurfaceTextureClient(11572): dequeueBuffer failed (No such device)
09-30 15:10:56.864: E/ViewRootImpl(11572): Could not lock surface
09-30 15:10:56.864: E/ViewRootImpl(11572): java.lang.IllegalArgumentException
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.view.Surface.nativeLockCanvas(Native Method)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.view.Surface.lockCanvas(Surface.java:452)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2264)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2227)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2095)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1904)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1039)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4417)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.view.Choreographer.doFrame(Choreographer.java:532)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.os.Handler.handleCallback(Handler.java:725)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.os.Handler.dispatchMessage(Handler.java:92)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.os.Looper.loop(Looper.java:137)
09-30 15:10:56.864: E/ViewRootImpl(11572): at android.app.ActivityThread.main(ActivityThread.java:5061)
09-30 15:10:56.864: E/ViewRootImpl(11572): at java.lang.reflect.Method.invokeNative(Native Method)
09-30 15:10:56.864: E/ViewRootImpl(11572): at java.lang.reflect.Method.invoke(Method.java:511)
09-30 15:10:56.864: E/ViewRootImpl(11572): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
09-30 15:10:56.864: E/ViewRootImpl(11572): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:596)
09-30 15:10:56.864: E/ViewRootImpl(11572): at dalvik.system.NativeStart.main(Native Method)
09-30 15:10:57.424: E/InputEventReceiver(11572): channel '41c547b0 com.example.testapk/com.example.testapk.ui.MainActivity (client)' ~ Publisher closed input channel or an error occurred. events=0x9
09-30 15:10:57.600: E/InputEventReceiver(11572): channel '41b6a120 com.example.testapk/com.example.testapk.ui.MDEActivity (client)' ~ Publisher closed input channel or an error occurred. events=0x9

代码如下:

public void discoverServices() {
    Log.i("sg_life", "start discover……");
    mNsdManager.discoverServices(SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD,
            mDiscoveryListener);
}

日志中第一行是调用discoverServices之前的日志,在mDiscoveryListener的onDiscoveryStarted方法里也加了输出但是日志上没有打出来。

        public void onDiscoveryStarted(String regType) {
            Log.e("sg_life", "Service discovery started……");
        }

因此暂时判断是discoverServices方法中出错。API中discoverServices方法如下

public void discoverServices(String serviceType, int protocolType, DiscoveryListener listener) {
    if (listener == null) {
        throw new IllegalArgumentException("listener cannot be null");
    }
    if (TextUtils.isEmpty(serviceType)) {
        throw new IllegalArgumentException("Service type cannot be empty");
    }

    if (protocolType != PROTOCOL_DNS_SD) {
        throw new IllegalArgumentException("Unsupported protocol");
    }

    NsdServiceInfo s = new NsdServiceInfo();
    s.setServiceType(serviceType);
    mAsyncChannel.sendMessage(DISCOVER_SERVICES, 0, putListener(listener, s), s);
}

再之后的代码小弟也没能力找到,根据报错日志也没有找到有用的信息。

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 MATLAB动图问题
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名