LWJGL GLFW hangs on native glfwInit call - java

I originally posted this question on GameDev stackexchange however I'll also ask the question here to try and get more outreach, especially since I wasn't sure my problem was specific to game development since it's a problem with a Java native call.
For the past months I've been working on creating my own game engine for personal use in LWJGL using pieces here and there, especially from developer ThinMatrix's rightfully credited code, to learn as much as I can while building it. Only recently there has been strange behavior happening when I launch the engine from IntelliJ for testing:
After about 6-10 individual times I click run, all subsequent runs suddenly take about 60 seconds for the window to appear.
Whenever I restart my PC this hanging resets and I have another 6-10 runs before it hangs everytime again.
I located the issue to glfwInit, more specifically at the call to the native method:
#NativeType("int")
public static boolean glfwInit() {
long __functionAddress = Functions.Init;
return invokeI(__functionAddress) != 0; // Right here
}
I also noticed that this issue only started when I attempted to implement text support in my engine using the STBTrueType library. It was perfectly fine before that. I tried removing the TrueType code but it didn't fix it.
Here's a list of things I've tried:
Clearing my temp folder in case a buggy or corrupted file was present.
Recompiling and rebuilding the entire LWJGL jars twice.
Building glfw.dll from the GLFW sources and replacing the glfw.dll in the native jars with the former.
Reinstalling Java and actually upgrading JDK versions (from 13.0.2 to 14.0.2)
Switching IDEs even if I suspected it wouldn't work.
Updating my NVIDIA drivers, and reinstalling them.
I'm quite confused as to what it could be, and I'd be more than happy to share code, thread dumps, or debug info if you deem it necessary. Here is the Github repository with the latest, "faulty" code (fault in quotes because I'm not too sure the code is the problem.)
Thank you very much for any guidance.
P.S: Please tell me if this is better asked in StackOverflow instead of here.

So I fixed the issue, it turns out it wasn't even related to anything to do with programming, or STBTrueType, or the library itself. The problem was as pointed out in this StackOverflow post, where this hanging behavior was due to a faulty driver or, in my case, my keyboard USB being plugged in the "wrong" USB port. I moved my computer at the same time I started working on text in my engine, hence why I wrongly linked the issue with the TrueType library. If you're having the same issue, look at the aforementioned post or if that doesn't work, look for a peripheral that might cause interference.

Related

Runnable .jar file not executed when double clicking

For quite some time I have encountered this issue that when doubleclicking a runnable .jar file it won't execute. Today I thought I'd have a look into solving this issue and read a bit through various SO articles regarding this topic.
First of all I have to say the following:
The problem occurs on my company's notebook running WIN 8 as well as on
my private WIN 10 desktop
I'm pretty sure about 1.5 - 2 years ago on the laptop doubleclicking worked
On the desktop however even directly after installation (which was in October last year) doubleclicking didn't work and it might be that I even already tried fixing the issue by reinstalling the JRE
As opposed to many situations described in various posts I can properly run the applications by calling "java -jar application.jar" in cmd but doubleclicking AS WELL AS trying to "open with" Java SE platform binary results in nothing happening
As suggested by several posts I tried running Jarfix however now the behaviour is as follows:
I had written a client-server application for my bachelor thesis which worked perfectly fine, I actually ran the application yesterday through cmd. After using Jarfix I'm now able to start the server by doubleclicking whereas the client side won't do anything when doubleclicked. I already checked for the correct filetype association as described in this post and everything looks correct.
Also I of course checked this with different programs as well and not only with my own applications. The same issue also appears for example (on my WIN 10 desktop) when trying to run Life in the Woods (for those not knowing it, it's a quite popular Minecraft mod pack) whereas it worked perfectly fine on my previous WIN 10 desktop when doubleclicking.
The problem that I have with this issue is not that I'd not be able to bypass it by running cmd commands but on the one hand it's simply annoying to always cd to the desired location and run this command and on the other hand it's simply something that has to definitely work after installing a JRE. It doesn't make any sense that for most people it works and for some few people random stuff happens - all more or less under the same conditions, that's not how any kind of software should behave.
I'd be really happy if anyone could help me solving this or point me towards anything I might have overlooked and forgot to check.
EDIT:
As pointed out by #VGR file operations using relative paths might be the reason for the problem hence below the two cases where file operations are being used:
Server-side:
File file = new File("C:/Util/authHashes.lvs");
Client-side:
systemProperties.put("javax.net.ssl.keyStore", "C:/Util/auth/labkey.jks");
systemProperties.put("javax.net.ssl.keyStorePassword", "password");
systemProperties.put("javax.net.ssl.trustStore", "C:/Util/auth/labtrust.jks");
What is weird is that both classes use absolute paths but the server starts when doubleclicking while the client does not. If both use the same kind of path shouldn't they both behave exactly the same?

Visual Studio Code - lagging when typing

I have just installed Visual Studio Code together with the Java Extension Pack. However, when I opened my first file and started typing, the text I type appears after a delay - reaching up even one second.
I have a hunch that it might be due to the number of processes going behind the editor, like real-time syntax checking, autocompletion, code hints et cetera. Perhaps the laptop I am working at simply cannot handle that much. These are the parameters of my current machine:
Processor: Intel(R) Caleron(R) CPU N3350 (1.10 GHz)
RAM: 4 GB
I have another hunch that it may be due to the processor.
So, are there a ways to switch off these facilities like real-time error-checking? If not, what other IDEs for Java could you reccomend? (Apart from Eclipse)
Had the same problem using Visual Studio Code while using Android Studio along with an Android Simulator in the background, and I run 8GB RAM and a CPU of 3.2GHz but when I returned to Notepad++ (I know its suicidal), to check if it is my problem or because of the IDEs, I typed in real time.
It is due to your processor as Visual Studio Code is not really recommended for "slow" CPUs. Personally I like it, although an IDE in the likes of Vim might suit you better.
Here is a link that might give some more hints:
https://github.com/Microsoft/vscode/issues/38409
The easiest solution I found was to download and install Visual Studio Code Insiders. It's nearly identical except that it's known to lag less. Installing this will also clear any extensions or preferences you have enabled which might be causing the lag:
https://code.visualstudio.com/insiders/
You may also need to run it from the command line with the --disable-gpu flag
code-insiders --disable-gpu
or
/Applications/Visual\ Studio\ Code\ -\ Insiders.app/Contents/MacOS/Electron --disable-gpu
depending on your OS
Try the following steps:
Disable any unnecessary extensions.
Update to the stable version.
If this still hasn't worked, try reinstalling your Visual Studio Code instance.
Same for me, I often let the computer sleep instead of turn off and kill all processes so it was normal for me that the VS was open for a few days, the solution was to close visual studio and reopen it.
maybe its the computer performance issue. i am using a laptop.
yesterday i uninstall large program (MS SQl server)
now typing speed back to normal.
I've now had this problem a number of times. As a matter of fact I just had it right now.
What solves it for me is to
Close VS code
Unpin it from my taskbar
Pin it back
It works well after that.
Closing and reopening VS Code has never worked for me
Please disable Spring Boot Tools from Pivotal!!!
This extension doesn't work well with other Java extesions.(ie. Extesion pack for Java and Language support for Java)
After disabling it, I've seen significant speed increase with Intellisense, and CPU load reduced as a result. Please get rid of the thing!!!

Differences in execution behavior of Java program

I wrote a java program, which manipulates Word documents (docx) with Apache POI. It runs fine within Eclipse, and it runs fine as a runnable JAR on my computer (Windows 10).
I copied that JAR to another computer, and it is starting up normally. The GUI behaves like expected.
The problem is the Word document I write out (docx).
I am performing two types of changes. The first one is the addition of new paragraphs or concatenation of content to the runs. If I stay with this, the document gets written into the file system correctly. The second type is the simple replacement of content within the runs (changes of words and some grammatical changes). I would see that part as the "simpler" one, but if I stay with this or if I combine both change types, no document is written out at all. It does look like there is a bug, but there isn't one because it worked fine on my system.
I wrote myself a function to write out an error log (txt) to get information about that issue. This one worked on both systems. But the log didn't get any information, why the document was not written out.
I suppose there are some Windows security settings which interfer with my program or something like that. The computer that does not like to run my program has Win 7 installed on it, and there are some security domain settings, which affect all other computers in the local network.
Does anyone experienced something similar yet? Any suggestions what to check? Suggestions how to find out if an error happened are appreciated as well.
OK, the problem got solved by simply updating the Java version. I saw that update icon in the system tray, which didn't open update the update dialog. So I wanted to update the Java-version at least.
When I wanted to de-install the current Java version first, I noticed that the Win7-machine hadn't a Java-update for three years now. It was just installed in 2014. As soon as the recent version was installed, everything worked like expected again.
The strange behavior that some parts of my program worked and some not, confused me. I hoped that the Java update would fix this, but I doubted that. I didn't knew that old versions make programs run unpredictably.

jogl program starting extremely slow

Im trying to get a project with JOGL running and from second one I've run into problems. I have downloaded jogl-all.jar, gluegen-rt.jar and gluegen-rt-natives-windows-amd64.jar and jogl-all-natives-windows-amd64.jar version 2.3.2 from the release website of JOGL. I have extracted gluegen-rt.jar and jogl-all.jar, added them as a library to my project and put all the native files into lib/natives/windows-amd64. So far so good, I then set up a simple method doing the following:
System.out.println("Start");
GLProfile profile = GLProfile.getDefault();
System.out.println(profile.getImplName());
I hit the run button in IntelliJ and it printed "Start". Thats it. I started checking some logs, browsing the internet about that issue and suddenly, like 2 minutes later I realized in the corner of my eye that the output changed and it printed GL4bc. A little bit confused i thought this might be some IntelliJ related issue or so and started it in the command line. Same thing there, it consistently takes 1-2 minutes to execute GLProfile.getDefault(). What's this madness? I mean, I never choose Java for performance reasons, but that's a little bit too much :D.
What am I missing here? Or is this 'as designed'? Thanks for any help in advance and have a nice day!

Replacing/Rebuilding framework.jar in Android Source

This could be a rather crazy question, but I wanted to get some insight on it before I spend all the time trying it.
Is it possible to rebuild framework.jar (like say pulling the framework.jar from MIUI), decompile it to smali and then rebuilt it from scratch (via reading through and remaking it yourself into java)?
I planned on doing that + taking the similar files from Cyanogen mod as a reference to build off of. The reason I was interested in doing all this was because I have a phone that needs the Radio Interface Layer more or less rebuilt and it's just become too much of a hassle to deal with editing the smali directly and debugging it.
I figured I would ask here because people would be less quick to rush to judgment on whether it was possible or not. I don't see why it wouldnt work if you are adding everything correctly (in theory) and rebuilt the classes.dex file in the source after.
Main reason I am asking is part of an effort to port MIUI to my phone. I figured the lesser of too headaches was rewriting the java and rebuilding a working framework.jar (which has parts in it that are not in the CM7 or AOSP sources) than editing the framework.jar that comes with MIUI to work correctly.
While there are various ways to decompile a dex file back into java, none of them will produce java that is perfectly compilable. You would have to spend tons of effort cleaning up the java code from a decompiler, to get it to compile. It's pretty much not an option for something as big as that.
Your best bet is to get something like AOSP or CM working on your phone, so that you can build the framework yourself directly, with whatever modifications you need.

Categories