Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26585] Android: Liveview throws exception due to null object reference with latest 8.0.0

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2018-12-19T01:15:58.000+0000
Affected Version/sRelease 8.0.0
Fix Version/sRelease 8.0.0
ComponentsAndroid, LiveView
Labelsregression
ReporterLokesh Choudhary
AssigneeGary Mathews
Created2018-11-20T21:04:37.000+0000
Updated2019-01-16T23:23:02.000+0000

Description

This is a regression.

Steps to reproduce:

1. Build and launch an Android app to device/simulator with liveview turned on. 2. Make changes to any property so that reload of the app is triggered.

Actual results:

1. After the app launch we see Address in use, retrying... in the studio console. 2. After a property is changed & app reloads below exception is thrown:
[ERROR] :  [Nexus 6P] TiExceptionHandler: (main) [290,9951] Attempt to invoke virtual method 'java.io.InputStream java.net.Socket.getInputStream()' on a null object reference
[ERROR] :  [Nexus 6P] TiExceptionHandler:
[ERROR] :  [Nexus 6P] TiExceptionHandler:     ti.modules.titanium.network.socket.TCPProxy.readSync(TCPProxy.java:392)
[ERROR] :  [Nexus 6P] TiExceptionHandler:     ti.modules.titanium.stream.StreamModule.pumpSync(StreamModule.java:359)
[ERROR] :  [Nexus 6P] TiExceptionHandler:     ti.modules.titanium.stream.StreamModule.access$300(StreamModule.java:24)
[ERROR] :  [Nexus 6P] TiExceptionHandler:     ti.modules.titanium.stream.StreamModule$3.run(StreamModule.java:343)
[ERROR] :  [Nexus 6P] TiExceptionHandler:     java.lang.Thread.run(Thread.java:764)
NOTE: The app reloads fine & the necessary changes are seen behind the runtime error in the device.

Expected result:

1. No runtime error is seen & liveview works as expected.

Comments

  1. Ewan Harris 2018-11-21

    [~lchoudhary] I'll take a look into this, the "address in use" error is probably down to the dual liveview hook situation going on in 5.1.2 studio/sdk 8.0.0, I asked for TISTUD-9119 to be considered to 5.1.2 and raised the as a potential issue for the 8.0.0 release.
  2. Ewan Harris 2018-11-26

    [~gmathews], this looks to be coming from Java-land in the SDK. I'm guessing it's either related to the _restart method in the SDK not disposing of everything correctly or something in the HTTPClient stuff? The liveview version works fine for me on SDK 7.5.0 Any ideas? It looks to be beyond my knowledge :)
  3. Gary Mathews 2018-11-26

    master: https://github.com/appcelerator/titanium_mobile/pull/10490
  4. Joshua Quick 2018-11-26

    [~eharris], this exception will happen if the JavaScript HTTPClient was closed and then re-used while closed. I don't see how our Java code changes in the past release would cause this error. Even the past release would have thrown an exception. It would have turned the Java exception into a JavaScript exception. (I'm still approving Gary's PR anyways since it's an improvement.)
  5. Ewan Harris 2018-11-27

    [~jquick] Just my 2c (with added limited knowledge) but the area of code that the errors being thrown from looks to have undergone a fair few changes in 8.0.0 https://github.com/appcelerator/titanium_mobile/pull/10347. That with the fact that I was unable (and based off the ticket so was Lokesh) to reproduce this led me to believe it might be more on the native side than liveview itself. It might just be that liveview needs to adapt to those changes.
  6. Lokesh Choudhary 2018-11-27

    [~jquick], [~eharris], [~gmathews] - As I mentioned in the Asia standup yesterday now I am seeing this with 7.5.0.GA as well. I have asked Keerthi to give it a shot as I want to rule out if its an issue with my network (not likely though). Also, I don't see any liveview related changes going in studio 5.1.2. But I am going to try it with latest GA studio.
  7. Lokesh Choudhary 2018-11-27

    GA studio & 7.5.0.GA looks fine for me. Keerthi was seeing the address in use ... in the console as well. She was testing with 8.0.0 earlier before moving to 5.1.2 studio & 7.5.0.GA for smokes. I restarted my machine & I am seeing the issue 100% with latest 8.0.0 SDK. But yesterday was seeing it with 7.5.0.GA (this is a mystery) but now I don't see it.
  8. Gary Mathews 2018-11-28

    A quick update here is that prior LiveView servers are not terminating when they should. This holds onto the port that needs to be used by any new LiveView servers. Which is why you are seeing "Address in use, retrying..." [~eharris] may know more about why this is happening?
  9. Ewan Harris 2018-12-04

    Missed that ping, there is a known around liveview servers not being killed always (TIMOB-25821), this generally isn't an issue as liveview will attempt to kill any existing servers on startup, but it only calls localhost:8324 so if you're using custom IPs/ports then there's issues (TIMOB-25823). I don't think this is what Lokesh is seeing though, when building with SDK 8 you're pulling in the liveview hook from Studio AND the hook from the SDK (we can't remove the Studio hook for compatibility reasons). TISTUD-9119 aimed to mitigate this by making the hook in Studio a no-op on SDK 8 or above. The problem here is that fix is only shipping in 6.0.0 (despite my requests), this means that when you run a build you'll be having two liveview servers attempting to start, causing the "address in use" issue. If you use Studio 6 then you shouldn't see this issue.
  10. Lokesh Choudhary 2018-12-14

    One thing to note is I do get the exception above when live view is run from CLI as well.
  11. Lokesh Choudhary 2018-12-19

    PR Merged. Part of this fix will in studio 5.1.2.GA
  12. Lokesh Choudhary 2019-01-16

    Verified the fix with SDK 8.0.0.v20190115162133 & studio 5.1.2. Closing. Studio Ver: 5.1.2.201812191831 SDK Ver: 8.0.0.v20190115162133 OS Ver: 10.14 Xcode Ver: Xcode 10.1 Appc NPM: 4.2.13 Appc CLI: 7.0.10-master.5 Daemon Ver: 1.1.3 Ti CLI Ver: 5.1.1 Alloy Ver: 1.13.7 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 10.0.2 Devices: ⇨ google Nexus 5 (Android 6.0.1) ⇨ google Pixel (Android 9)

JSON Source