JnCrMx / discord-game-sdk4j

Java bindings for Discord's Game SDK
MIT License
122 stars 23 forks source link

Program closing unexpectedly when calling Core constructor #8

Closed schitcrafter closed 3 years ago

schitcrafter commented 3 years ago

Basically the headline. I can execute Core.init() without any error, create the Params and everything just fine, and then I construct a new Core object. My program then exits, without calling finalize / shutdown hooks. Discord switches to the Games tab (where all your Games are listed). I didn't change any code that would interfere with Discord, I use the same code which has worked for a couple weeks now, but it failed just today. From debugging I found out that it probably crashes somewhere in the create() native method.

the code I use:

    String discordLibraryName;
    if(System.getProperty("os.name").toLowerCase().contains("windows"))
    {
        discordLibraryName = "discord_game_sdk.dll";
    }
    else
    {
        discordLibraryName = "discord_game_sdk.so";
    }
    Core.init(new File("libraries\\de\\jcm\\discordgamesdk\\natives\\" + discordLibraryName));

    CreateParams params = new CreateParams();
    params.setClientID(CLIENT_ID);
    params.setFlags(CreateParams.getDefaultFlags());

    core = new Core(params); // fails here

    Activity activity = new Activity();

    // set activity stuff (I removed this, there's actual code here)

    core.activityManager().updateActivity(activity);
    activity.close();
JnCrMx commented 3 years ago

Hmm... I sadly cannot reproduce the error. Is there any sort of crash report on console or a minidump/crash log file?

If not, please set the flags in CreateParams to 1 (which translates to DiscordCreateFlags_NoRequireDiscord). Without this flag the SDK will terminate your application, if Discord isn't running. With this flag set, you will at least get a Java exception if the SDK fails to communicate with Discord.

Setting this flag will probably not solve the issue, but it might help to gather more information about it. Please also tell me which OS and Java version you are using.

schitcrafter commented 3 years ago

I feel like an idiot. For some reason, it now works perfectly fine. I gotta remember to restart my PC and test again before making a issue.

Thank you for responding so quickly tho

JnCrMx commented 3 years ago

No problem, this has happened to all of us :) But I'm glad that it works again now. :partying_face: