Industrial Foregoing

Industrial Foregoing

95M Downloads

Blocking I/O on main thread

3TUSK opened this issue ยท 2 comments

commented

Industrial Foregoing Version: 1.12.11 (to be more precise, I am looking at d8170bd)
TeslaCoreLib Version: 1.12.2-1.0.15 (remark: this issue has nothing to do with TeslaCoreLib)
Crashlog (If Any): N/A

In com.buuz135.industrial.proxy.CommonProxy, we have this for retrieving a contributor list:

https://github.com/Buuz135/Industrial-Foregoing/blob/d8170bd9e307afd2ebfaa97ca692d0b98414e0ad/src/main/java/com/buuz135/industrial/proxy/CommonProxy.java#L195-L199

The readUrl call turns out to be a blocking I/O operation:

https://github.com/Buuz135/Industrial-Foregoing/blob/d8170bd9e307afd2ebfaa97ca692d0b98414e0ad/src/main/java/com/buuz135/industrial/proxy/CommonProxy.java#L92-L108

Under certain low-quality internet conditions, this call will cause the game initialization process to hang until timeout. The symptom looks just like the process enters a dead loop.
The preferred way to handle this is to retrieve this list on a separate thread, i.e. something like this:

new Thread(() -> {
  new JsonParser().parse(readUrl(CONTRIBUTORS_FILE))....;
}).start();
commented

Can you fix this quicker? It has stuck my game start so many times, especially in Linux environment. @TheCodedOne

photo_2019-11-03_13-02-39

commented

๐Ÿ‘‹ Sorry but Industrial Foregoing has ended support for version 1.12. I'm closing this issue as it will no longer be updated for that version. Thanks for playing with the mod.