我正在尝试从单独的线程连续发送HTTP请求(完整描述和代码here)。
说得很简短,我enqueue()
在一段时间内请求一次(如果周期为50毫秒,500毫秒或1秒无关紧要),并且在发送一些请求之后(或者更确切地说是在一段时间之后) )系统冻结okhttp3
线程将这样的内容打印到logcat
(此处延迟12秒!):
03-29 08:34:17.898 21167-21167/com.example.control D/CommandSender: http://192.168.1.185/drive?m1s=801&m2s=805&dir=ff s: 204 f: 3
03-29 08:34:18.108 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:18.379 21167-21167/com.example.control D/CommandSender: http://192.168.1.185/drive?m1s=732&m2s=919&dir=ff s: 205 f: 3
03-29 08:34:18.619 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:18.919 21167-21167/com.example.control D/CommandSender: http://192.168.1.185/drive?m1s=769&m2s=927&dir=ff s: 206 f: 3
03-29 08:34:19.210 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:19.740 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:20.291 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:20.451 505-919/? D/Process: killProcessQuiet, pid=9971
03-29 08:34:20.451 505-919/? I/ActivityManager: No longer want com.maxmpz.audioplayer (pid 9971): hidden #16, adj=15
03-29 08:34:20.461 505-919/? D/Process: dalvik.system.VMStack.getThreadStackTrace(Native Method)
03-29 08:34:20.461 505-919/? D/Process: java.lang.Thread.getStackTrace(Thread.java:599)
03-29 08:34:20.461 505-919/? D/Process: android.os.Process.killProcessQuiet(Process.java:837)
03-29 08:34:20.461 505-919/? D/Process: com.android.server.am.ActivityManagerService.updateOomAdjLocked(ActivityManagerService.java:15735)
03-29 08:34:20.461 505-919/? D/Process: com.android.server.am.ActivityManagerService.setProcessForeground(ActivityManagerService.java:5041)
03-29 08:34:20.461 505-919/? D/Process: com.android.server.NotificationManagerService.keepProcessAliveLocked(NotificationManagerService.java:750)
03-29 08:34:20.461 505-919/? D/Process: com.android.server.NotificationManagerService.enqueueToast(NotificationManagerService.java:619)
03-29 08:34:20.461 505-919/? D/Process: android.app.INotificationManager$Stub.onTransact(INotificationManager.java:104)
03-29 08:34:20.461 505-919/? D/Process: android.os.Binder.execTransact(Binder.java:338)
03-29 08:34:20.461 505-919/? D/Process: dalvik.system.NativeStart.run(Native Method)
03-29 08:34:20.491 209-7892/? D/memalloc: ion: Allocated buffer base:0x41cb5000 size:147456 fd:38
03-29 08:34:20.491 21167-21167/com.example.control D/memalloc: ion: Mapped buffer base:0x52fe5000 size:147456 offset:0 fd:99
03-29 08:34:20.511 209-277/? I/Adreno200-EGLSUB: <CreateImage:897>: Android Image
03-29 08:34:20.511 209-277/? I/Adreno200-EGLSUB: <GetImageAttributes:1106>: RGBA_8888
03-29 08:34:20.521 890-890/? D/dalvikvm: GC_FOR_ALLOC freed 1160K, 36% free 5526K/8611K, paused 41ms
03-29 08:34:20.541 505-763/? W/ContentService: binderDied() at ObserverNode
03-29 08:34:20.541 505-763/? W/ActivityManager: Scheduling restart of crashed service com.maxmpz.audioplayer/.player.HeadsetMicroService in 5000ms
03-29 08:34:20.571 902-902/? I/PreJBNotificationService: onAccessibilityEvent
03-29 08:34:20.911 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:21.432 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:22.103 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:22.463 21167-21167/com.example.control D/memalloc: ion: Unmapping buffer base:0x52fe5000 size:147456
03-29 08:34:22.503 209-7961/? D/memalloc: ion: Allocated buffer base:0x41e02000 size:147456 fd:66
03-29 08:34:22.503 21167-21167/com.example.control D/memalloc: ion: Mapped buffer base:0x52fe5000 size:147456 offset:0 fd:99
03-29 08:34:22.513 209-277/? D/memalloc: ion: Freeing buffer base:0x41cb5000 size:147456 fd:38
03-29 08:34:22.513 209-277/? D/memalloc: ion: Unmapping buffer base:0x41cb5000 size:147456
03-29 08:34:22.513 209-277/? I/Adreno200-EGLSUB: <CreateImage:897>: Android Image
03-29 08:34:22.513 209-277/? I/Adreno200-EGLSUB: <GetImageAttributes:1106>: RGBA_8888
03-29 08:34:22.533 890-890/? D/dalvikvm: GC_FOR_ALLOC freed 1158K, 36% free 5526K/8611K, paused 51ms
03-29 08:34:22.563 902-902/? I/PreJBNotificationService: onAccessibilityEvent
03-29 08:34:22.603 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:23.004 505-543/? D/BatteryService: updateBatteryStats ======================================
03-29 08:34:23.134 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:23.154 505-557/? D/BatteryService: UEvent updateBatteryStats
03-29 08:34:23.164 505-543/? D/HtcPowerSaver: Recived battery changed intent.
03-29 08:34:23.164 505-543/? D/UsbnetService: BroadcastReceiver::onReceive+
03-29 08:34:23.164 505-543/? D/UsbnetService: onReceive BATTERY_CHANGED
03-29 08:34:23.164 505-543/? D/UsbnetService: --> pluggedType = 2, mPluggedType = 0, mScreenOff = false
03-29 08:34:23.164 505-543/? D/UsbnetService: BroadcastReceiver::onReceive-
03-29 08:34:23.164 505-543/? D/HtcPowerSaver: Checking...
03-29 08:34:23.164 505-543/? I/HtcPowerSaver: >> updateStatus
03-29 08:34:23.164 505-543/? I/HtcPowerSaver: currentStatus=8000, currentLevel=93, enableLevel=20, enable=false, popDialog=false, statusChangeTo=-1
03-29 08:34:23.164 505-543/? I/HtcPowerSaver: << updateStatus
03-29 08:34:23.164 505-557/? D/PackageManager: Failed to get PackageInfo!, pkg:com.htc.demoflorebooter, flags:1
03-29 08:34:23.164 647-647/? D/StatusBar.BatteryController: updateBattery level=93 icon=17302788 status=2
03-29 08:34:23.164 647-647/? D/PowerUI: closing low battery warning: level=93
03-29 08:34:23.164 647-647/? D/PowerUI: plugged = true, health = 2, mBatteryLevel = 93, mPluggedBatteryLevel = 91, mLowBatteryWarningLevel2 = 25, mshowLowChargingWarning2 = true
03-29 08:34:23.164 505-543/? D/NotificationService: mIntentReceiver() Intent.ACTION_BATTERY_CHANGED
03-29 08:34:23.164 505-543/? D/PowerManagerService: runHtcPowerSaverCheck ======================================
03-29 08:34:23.634 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:24.285 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:24.465 21167-21167/com.example.control D/memalloc: ion: Unmapping buffer base:0x52fe5000 size:147456
03-29 08:34:24.505 209-277/? D/memalloc: ion: Freeing buffer base:0x41e02000 size:147456 fd:66
03-29 08:34:24.505 209-277/? D/memalloc: ion: Unmapping buffer base:0x41e02000 size:147456
03-29 08:34:24.785 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:25.296 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:25.566 505-544/? I/ActivityManager: Start proc com.maxmpz.audioplayer for service com.maxmpz.audioplayer/.player.HeadsetMicroService: pid=23572 uid=10203 gids={1015, 3003, 3002}
03-29 08:34:25.807 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:25.807 23572-23572/? I/dalvikvm: Could not find method com.maxmpz.audioplayer.Application.getExternalFilesDirs, referenced from method com.maxmpz.audioplayer.Application.ll11
03-29 08:34:25.807 23572-23572/? W/dalvikvm: VFY: unable to resolve virtual method 5688: Lcom/maxmpz/audioplayer/Application;.getExternalFilesDirs (Ljava/lang/String;)[Ljava/io/File;
03-29 08:34:25.807 23572-23572/? D/dalvikvm: VFY: replacing opcode 0x6e at 0x002e
03-29 08:34:25.827 23572-23572/? W/audioplayer.Application: Detected NEON support
03-29 08:34:25.827 23572-23572/? W/audioplayer.Application: Detected HTC
03-29 08:34:25.827 23572-23572/? I/dalvikvm: Could not find method android.widget.RemoteViews.setTextViewTextSize, referenced from method com.maxmpz.audioplayer.widgetpackcommon.CommonWidgetProvider.ll1l
03-29 08:34:25.827 23572-23572/? W/dalvikvm: VFY: unable to resolve virtual method 4565: Landroid/widget/RemoteViews;.setTextViewTextSize (IIF)V
03-29 08:34:25.827 23572-23572/? D/dalvikvm: VFY: replacing opcode 0x6e at 0x0007
03-29 08:34:25.827 23572-23572/? W/audioplayer.Application: htcSenseVersion=400
03-29 08:34:25.837 23572-23572/? I/audioplayer.Application: man=HTC pro=ville mod=HTC One S dev=ville type=user board=MSM8960 rel=4.0.4 osVersion=3.0.8-01575-gdcba118
03-29 08:34:25.837 23572-23572/? W/audioplayer.Application: Poweramp edition: arm-play
03-29 08:34:25.837 23572-23572/? I/ActivityThread: Pub com.maxmpz.audioplayer.data: com.maxmpz.audioplayer.rest.RestProvider
03-29 08:34:25.837 23572-23572/? W/audioplayer.Application: tab=false screenSize=2 dpi=240 den=1.5 swdp=360 w/h=540x960
03-29 08:34:25.887 212-212/? D/AudioFlinger: no match values for active_ap
03-29 08:34:25.887 212-212/? E/AudioHardwareALSA: unsupported AP: Music
03-29 08:34:25.887 212-455/? D/AudioFlinger: no match values for active_ap
03-29 08:34:25.887 212-455/? E/AudioHardwareALSA: unsupported AP: Music
03-29 08:34:25.887 212-30925/? D/AudioFlinger: no match values for active_ap
03-29 08:34:25.887 212-30925/? E/AudioHardwareALSA: unsupported AP: Music
03-29 08:34:26.287 647-647/? D/PhoneStatusBarPolicy: isCdma=false hasService=true mSimState=UNKNOWN gprsState=1 mDataState=0 dataActivity=3 htcModemLinkOn=false hspa=true
03-29 08:34:26.327 505-569/? I/PowerManagerService-JNI: [Stability] PowerManagerService_userActivity JNI pass power key event to PowerManagerService userActivity()
03-29 08:34:27.198 16321-16321/? I/hostapd: wlan0: AP-STA-CONNECTED 68:5d:43:da:ef:62
03-29 08:34:27.198 16321-16321/? I/hostapd: station join 68:5D:43:DA:EF:62
03-29 08:34:27.198 505-16290/? I/hostapd: handle event, recv=(<3>AP-STA-CONNECTED 68:5d:43:da:ef:62,37), result=0
03-29 08:34:27.198 505-16290/? I/hostapd: handle event: result=0 nread=37 string="<3>AP-STA-CONNECTED 68:5d:43:da:ef:62"
03-29 08:34:27.208 505-16290/? D/SoftapMonitor: received event=3, STA_JOIN
03-29 08:34:27.208 505-16290/? I/hostapd: Handle event.........
03-29 08:34:27.208 206-264/? D/QCSDK-: CMD INPUT
03-29 08:34:27.208 505-591/? D/Tethering: [isWifi] getHotspotEnabled: true
03-29 08:34:27.208 505-591/? D/WifiStateMachine: WiFiDisplay: getWifidisplayApEnabled=false
03-29 08:34:27.208 505-591/? D/WifiStateMachine: WiFiDisplay: getWifidisplayApEnabled=false
03-29 08:34:27.208 505-591/? D/Tethering: [isWifi] getWifidisplayApEnabled: false
03-29 08:34:27.208 505-591/? D/Tethering: [isWifi] iface: wlan0 && wifi.softap.interface: wlan0
03-29 08:34:27.208 505-591/? D/Tethering: interfaceStatusChanged wlan0, true
03-29 08:34:27.218 206-264/? D/QCSDK-: CMD OUTPUT [success sta_mac_list=5C:CF:7F:D5:07:EA 68:5D:43:DA:EF:62] len :56
03-29 08:34:27.218 505-596/? D/WifiStateMachine: cancel SoftAP sleep policy: mUser=2, syncGetWifiApState=13
03-29 08:34:27.218 505-596/? E/NetworkManagementService: DEBUG softap getassoclist: 2|5C:CF:7F:D5:07:EA,68:5D:43:DA:EF:62,
03-29 08:34:27.218 505-596/? D/WifiStateMachine: SoftAP update assoc list: mUser=2
03-29 08:34:27.228 505-600/? D/Tethering: >>>>>>receive ASSOC_LIST_CHANGE_ACTION<<<<<<
03-29 08:34:27.228 505-600/? D/WifiStateMachine: WiFiDisplay: getWifidisplayApEnabled=false
03-29 08:34:27.228 505-600/? D/WifiStateMachine: WiFiDisplay: getWifidisplayApEnabled=false
03-29 08:34:27.228 505-600/? D/Tethering: showTetheredNotification: 17303460
03-29 08:34:27.228 206-264/? D/QCSDK-: CMD INPUT
03-29 08:34:27.228 206-264/? D/QCSDK-: CMD OUTPUT [success sta_mac_list=5C:CF:7F:D5:07:EA 68:5D:43:DA:EF:62] len :56
03-29 08:34:27.228 505-600/? E/NetworkManagementService: DEBUG softap getassoclist: 2|5C:CF:7F:D5:07:EA,68:5D:43:DA:EF:62,
03-29 08:34:27.238 505-600/? D/Tethering: icon change: 17303460 -> 17303460
03-29 08:34:27.288 16330-16330/? I/dnsmasq: DHCPREQUEST(wlan0) 192.168.1.157 68:5d:43:da:ef:62
03-29 08:34:27.288 16330-16330/? I/dnsmasq: DHCPACK(wlan0) 192.168.1.157 68:5d:43:da:ef:62 AsusU32VJ
03-29 08:34:27.368 902-902/? I/PreJBNotificationService: onAccessibilityEvent
03-29 08:34:27.368 902-902/? I/PreJBNotificationService: icon: 17303460
03-29 08:34:27.368 902-902/? I/PreJBNotificationService: package: android
03-29 08:34:27.368 902-902/? I/PreJBNotificationService: Ongoing notification, returning
03-29 08:34:30.572 21167-21167/com.example.control D/CommandSender: http://192.168.1.185/drive?m1s=602&m2s=988&dir=ff s: 207 f: 5
我在HTC One S和Alcatel Idol 3上有类似的行为 - 软件中的硬件设备非常不同
同时在相同设备上的浏览器中使用JS页面发送相同的请求显示没有问题
那么它应该是一些okhttp3
误用还是更深层次的问题?有没有办法防止这种延误?