Guad / NativeUI

UI library for Grand Theft Auto V
MIT License
271 stars 112 forks source link

Random game crash with scripthookdotnet v2.0 #13

Closed sinand99 closed 9 years ago

sinand99 commented 9 years ago

Launching the menu like in your example:

if (!Pool.IsAnyMenuOpen()) TrainerMainMenu.Visible = !TrainerMainMenu.Visible;

it randomly crashes the game in the first or sometimes second launch:

Application: GTA5.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException Stack: at nativeCall() at GTA.Native.?A0xc46f6644.NativeTask.Run() at GTA.ScriptDomain.DoTick() at GTA.ScriptDomain.DoTick() at .ManagedTick()


Faulting application name: GTA5.exe, version: 1.0.393.4, time stamp: 0x55a62e42 Faulting module name: KERNELBASE.dll, version: 10.0.10240.16384, time stamp: 0x559f38c3 Exception code: 0xe0434352 Fault offset: 0x000000000002a1c8


OS: windows 10 GTA ver: 393.4 Scripthookdotnet: 2.0 NativeUI: latest build from your latest source

Guad commented 9 years ago

I'll look into it

sinand99 commented 9 years ago

Hello Guad Any updates on this bug?

Guad commented 9 years ago

I could not reproduce the bug. Make sure you've got the new requirements for using ScriptHookDotNet 2.0 on Windows 10

RainerHilmer commented 9 years ago

I just found you are using .net framework 4.0 but you need V4.5.2.

sinand99 commented 9 years ago

@RainerHilmer This is not the case. Windows 10 comes preloaded with .net framework 4.6.

@Guad To isolate the problem, I tried with only NativeUI example and it crashes also! It works fine when I remove NativeUI.dll from scripts folder and use any mod without menu. Are you sure that you are not calling some invalid natives in your draw method?

RainerHilmer commented 9 years ago

@sinand99 Your bug report above claims 4.0. Also, I am not sure if 4.6 is fully downward compatible to 4.5.2. Are you?

sinand99 commented 9 years ago

@RainerHilmer lol It is obvious that you know nothing about .net framework. All 4.x versions are "in-place" upgrades which means you do not need the previous versions. It will report 4.0 but actually the minor version is different. By the way, I'm discussing the issue with Guad, not you. If you don't have any useful information, don't waste my time.

RainerHilmer commented 9 years ago

@sinand99 No need to get insulting. I was only trying to help, asshole!

Guad commented 9 years ago

@sinand99 Did you install Visual C++ 2015 redistributable? @crosire suggested that was the issue. Let me know if that fixed it.

sinand99 commented 9 years ago

@Guad I'm developing on Visual Studio 2015 so it is already installed.

sinand99 commented 9 years ago

I analyzed the crash dump of GTA5.exe with WinDbg and found that the root cause is your instructional buttons. I disabled them and crash is gone!

Even when I set _pool.DisableInstructionalButtons = true, it still calls UpdateScaleform() method and Scaleform.Render2D() which causes the crash. You should not call those methods at all when instructional buttons are disabled.

sinand99 commented 9 years ago

@Guad I'm waiting for your fix to the bug

Guad commented 9 years ago

I can't test anything since ScriptHookV has not updated yet.

njames93 commented 9 years ago

@Guad This will be fixed in the next version of SHV.Net, I dont know how it has slipped under my radar for so long. Hopefully this will come sooner rather than later, there are also some other bugs causing the game to crash that are waiting for a release to fix. If you dont want to wait to fix it you could instead of using Render2D you could manually draw it with Native.Function.Call(Native.Hash._0x0DF606929C105BE1, InstructionButtons.Handle, 255, 255, 255, 255, 0);

sinand99 commented 9 years ago

@zorg93 Thanks a lot! This bug was driving me crazy so I disabled all scaleform calls and made a special build for myself. Any news for the shvdotnet 463 version?

Guad commented 9 years ago

@zorg93 Nice to hear, I'll fix it ASAP

njames93 commented 9 years ago

Once Crosire comes online I'll bug him about it, I have already made a pr for the fix

njames93 commented 9 years ago

Guad p.s. Im unknown modder on GTAF

Guad commented 9 years ago

Yeah I know, I thought you'd like to be referenced by your Github handle, or do you want me to change it?

njames93 commented 9 years ago

lol dont worry bout that, I never even saw your first post crediting me. I only said that from this reply http://gtaforums.com/topic/809284-net-nativeui/?p=1067986549 Remember I am the one using the fixed version of the net hook :P

njames93 commented 9 years ago

Crosire released 2.2 which fixes that issue

Guad commented 9 years ago

Awesome