Blocking I/O on main thread
3TUSK opened this issue ยท 2 comments
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:
The readUrl
call turns out to be a blocking I/O operation:
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();
Can you fix this quicker? It has stuck my game start so many times, especially in Linux environment. @TheCodedOne