Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any attempt to open the debugger throws a NetworkOnMainThread exception #96

Closed
aem opened this issue Apr 4, 2017 · 14 comments
Closed
Labels

Comments

@aem
Copy link

aem commented Apr 4, 2017

I apologize because I don't have a solid repro other than running my project, but I have narrowed it down to Haul because switching back to the react-native packager allows the app to function properly.

Current Behavior

When connecting to the remote debugger, the app crashes with a NetworkOnMainThreadException:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.hubspot.android.debug, PID: 13213
                  android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@bdb46cb -- permission denied for window type 2003
                      at android.view.ViewRootImpl.setView(ViewRootImpl.java:703)
                      at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
                      at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
                      at android.app.Dialog.show(Dialog.java:322)
                      at com.facebook.react.devsupport.DevSupportManagerImpl.showProgressDialog(DevSupportManagerImpl.java:808)
                      at com.facebook.react.devsupport.DevSupportManagerImpl.reloadJSFromServer(DevSupportManagerImpl.java:813)
                      at com.facebook.react.devsupport.DevSupportManagerImpl.handleReloadJS(DevSupportManagerImpl.java:648)
                      at com.facebook.react.ReactInstanceManager$3$1.run(ReactInstanceManager.java:420)
                      at android.os.Handler.handleCallback(Handler.java:751)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6119)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

To compound this problem, because the debugger tries to auto-reconnect, the only way to get the app to work is to uninstall and reinstall, otherwise this will get triggered on every launch.

Expected Behavior

I should be able to open the chrome debugger

Haul Configuration (webpack.haul.js)

module.exports = ({ platform }, { resolve }) => ({
  entry: `./index.${platform}.js`,
  resolve: Object.assign(resolve, {
    alias: Object.assign({
      Immutable: 'immutable'
    }, resolve.alias || {}, myAliases)
  })
});

Your Environment

software version
Haul latest
react-native 0.43.0
node 7.8.0
npm or yarn yarn 0.21.3
@satya164
Copy link
Member

satya164 commented Apr 4, 2017

Does your app have the Draw over other apps permission?

@aem
Copy link
Author

aem commented Apr 4, 2017

Yep

@satya164
Copy link
Member

satya164 commented Apr 4, 2017

Can you double check? Because according to the error message, it does not.

@aem
Copy link
Author

aem commented Apr 4, 2017

Ah, sorry. I posted the wrong stack trace, still had that on my clipboard from earlier. I've left the office for the day but tomorrow I can get the correct one in here

@grabbou
Copy link
Member

grabbou commented Apr 4, 2017

We were experiencing similar issues earlier today, I'll debug them on device in the morning.

@aem
Copy link
Author

aem commented Apr 5, 2017

Here's the crash:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.hubspot.android.debug, PID: 3154
                  android.os.NetworkOnMainThreadException
                      at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)
                      at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
                      at java.net.SocketOutputStream.write(SocketOutputStream.java:157)
                      at okio.Okio$1.write(Okio.java:78)
                      at okio.AsyncTimeout$1.write(AsyncTimeout.java:180)
                      at okio.RealBufferedSink.emit(RealBufferedSink.java:178)
                      at okhttp3.internal.ws.WebSocketWriter.writeControlFrameSynchronized(WebSocketWriter.java:152)
                      at okhttp3.internal.ws.WebSocketWriter.writeClose(WebSocketWriter.java:111)
                      at okhttp3.internal.ws.RealWebSocket.close(RealWebSocket.java:168)
                      at com.facebook.react.devsupport.JSDebuggerWebSocketClient.closeQuietly(JSDebuggerWebSocketClient.java:144)
                      at com.facebook.react.devsupport.WebsocketJavaScriptExecutor$3.run(WebsocketJavaScriptExecutor.java:146)
                      at android.os.Handler.handleCallback(Handler.java:751)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6119)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

It seems like there may be more networking issues as well. Seeing hundreds of instances of this log message in the application logs:

W/OkHttp: A connection to http://10.0.2.2:8081/ was leaked. Did you forget to close a response body?

@grabbou
Copy link
Member

grabbou commented Apr 5, 2017

I've done some tests and managed to reproduce this crash. So far it seems to be happening only when debugger is being opened for the first time. Having it opened from previous session and running the app seems to work fine.

Looking into it now.

@ferrannp ferrannp added the bug label Apr 5, 2017
@aem
Copy link
Author

aem commented Apr 5, 2017

Another think I'm noticing is that the debugger continually tries to load on 10.0.2.2 (which I indicated above), I have to manually change the URL to localhost

@grabbou
Copy link
Member

grabbou commented Apr 5, 2017

That has been already fixed (see open PR).

@aem
Copy link
Author

aem commented Apr 5, 2017

Oops, thanks @grabbou, didn't see the linked PR

@aem
Copy link
Author

aem commented Apr 5, 2017

Looks to be more networking issues at play. Upgraded to 0.3.0 and now I see a message CANNOT TRANSLATE guest DNS ip logged to the device console (not the application logs) every 4 seconds or so. With this, I can't actually run any react native code. The app starts up fine (reactContext is non null, any statements in my index.android.js file are executed) but trying to load a component fails silently. See description of the problem here: http://stackoverflow.com/questions/43229683/react-native-component-not-mounting

@aem
Copy link
Author

aem commented Apr 6, 2017

^^ after a little more playing that all looks to be related more to react-native than haul, can close this in lieu of an issue over there: facebook/react-native#13340

@grabbou grabbou closed this as completed Apr 6, 2017
@aem
Copy link
Author

aem commented Apr 16, 2017

whoops. may have closed this prematurely. was this where the issue of opening the debugger causing a NetworkOnMainThread exception was being tracked? that's still an issue in 0.5.0

@satya164
Copy link
Member

As per your previous reply, this is an issue in React Native and not haul. So there's not much point of keeping this issue open. It's not actionable for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants