Kagamia / WzComparerR2

Maplestory online Extractor
MIT License
407 stars 134 forks source link

程序在启动一段时间后崩溃 #196

Open eikyu625 opened 2 years ago

eikyu625 commented 2 years ago
2/16/2022 2:53:55 PM
System.ArgumentException: Parameter is not valid.
   at System.Drawing.Bitmap..ctor(Type type, String resource)
   at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
   at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t)
   at System.Windows.Forms.Control.WndProcException(Exception e)
   at System.Windows.Forms.Control.ControlNativeWindow.OnThreadException(Exception e)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

程序启动后,就会以大约每秒20M的速度增加内存占用,然后在上升到1.5G后崩溃。期间GPU使用率小幅度上升。即使不载入任何wz,仍然可以观测到这个问题。 使用较旧的版本(20200426)没有此问题。 新版本,至少自从半年前的版本至今,都存在此问题。 较早的版本除了以上的错误,还会报告OOM。

12/24/2021 5:53:29 PM
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at WzComparerR2.Controls.AlphaForm.OnFormClosing(FormClosingEventArgs e)
   at System.Windows.Forms.Form.RaiseFormClosingOnAppExit()
   at System.Windows.Forms.Application.ExitInternal()
   at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t)
   at System.Windows.Forms.Control.WndProcException(Exception e)
   at System.Windows.Forms.Control.ControlNativeWindow.OnThreadException(Exception e)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

不排除显卡硬件故障,因为使用的显卡体质较差。

Kagamia commented 2 years ago

程序的确在使用GPU渲染图片资源,帧动画,纸娃娃动画,在主界面中以每秒30帧速度刷新,直接引用的框架是monogame-dx

过去半年最大的改动是我们更新了monogame的版本:https://github.com/Kagamia/WzComparerR2/commit/1f3bf87b262427513d0d52bcf5770a04b374dd5c 不确定是否存在相关性。

可以提供一下当前的系统硬件和软件(操作系统版本,.net版本等)配置吗

eikyu625 commented 2 years ago

我不确定都需要哪些信息。 操作系统是Windows 11 22543.1000 .NET使用注册表查看的方法可以看到大概是4.8或以上(Release=533302),关于中的CLR版本是4.0.30319.42000 并没有特别的安装过.NET,应该是系统或Visual Studio的C#套件自带的版本。 硬件..显卡是GTX750 TI

Kagamia commented 2 years ago

Windows 11 22543.1000是preview版本,正式版依然停留在22000,对于测试版windows和特定硬件上的错误,我们无能为力复现或者修复这种异常行为。

如果可以的话,您可以尝试如下操作:

  1. 使用nvidia control panel切换wcR2使用的GPU为核心显卡/独立显卡,看看能否修复或缓解
  2. 使用vs在debug模式下运行,查看是否有内存泄露情况,如果有,使用vs提供的内存分析工具查看内存占用的类型
  3. 当有确切的证据或数据后,report to Monogame Community/Microsoft
eikyu625 commented 2 years ago

更换显卡后问题解决。确认是硬件故障。

eikyu625 commented 2 years ago

我尝试使用Visual Studio的内存分析工具来捕获内存占用类型,但是他捕获不到主线程以外的数据,至少看起来内存使用情况快照报表一切正常。您方便说明如何捕获这一异常吗。 因为我有其他使用Windows 11非浏览版的朋友也遇到了同样的问题。猜测可能是Monogame在Win11部分显卡下兼容性存在问题,或其他的什么。 image

Windows 11 22543.1000是preview版本,正式版依然停留在22000,对于测试版windows和特定硬件上的错误,我们无能为力复现或者修复这种异常行为。

如果可以的话,您可以尝试如下操作:

  1. 使用nvidia control panel切换wcR2使用的GPU为核心显卡/独立显卡,看看能否修复或缓解
  2. 使用vs在debug模式下运行,查看是否有内存泄露情况,如果有,使用vs提供的内存分析工具查看内存占用的类型
  3. 当有确切的证据或数据后,report to Monogame Community/Microsoft
Kagamia commented 2 years ago

@zjb625 确实很奇怪... 请问您有试图切换过程序使用的网卡吗(比如在nvidia控制面板中设置,对特定程序使用核心显卡or独立显卡)

我在思考是否应该先排除是操作系统故障/特定硬件故障/特定驱动故障

eikyu625 commented 2 years ago

@zjb625 确实很奇怪... 请问您有试图切换过程序使用的网卡吗(比如在nvidia控制面板中设置,对特定程序使用核心显卡or独立显卡)

我在思考是否应该先排除是操作系统故障/特定硬件故障/特定驱动故障

抱歉最近有些忙回复有点慢。正如之前所说,我尝试更换了显卡,他可以正常工作了,因此我之前觉得是我那个五手矿卡的问题。但是我朋友在他的Windows11下也遇到了同样的问题,我认为同时遇到硬件故障的概率没那么高,因此判定应该不是硬件故障。应该是操作系统或驱动问题,或者两者都有。抱歉可能无法提供太有效的信息...可以断定的是渲染器问题,早些时候他应该问过你关于此的调用位置,注释后程序工作正常。

eikyu625 commented 2 years ago

为此更换了显卡为RX590, 问题仍然存在,且更换之前可以正常运行的显卡后也不再可以正常运行了...排除硬件问题.

Kagamia commented 2 years ago

如果是发生在特定windows的内部测试版本,那无论如何都很难复现类似错误的。

KENNYSOFT commented 1 year ago

Someone in the KMS community reported a similar issue also: increasing 20MB/s.

image

He/she said that it occurs even before opening Wz files, and commenting out the below line mitigates the issue.

https://github.com/Kagamia/WzComparerR2/blob/56cf982d006f0be2514aa883b5711b6c707845be/WzComparerR2.Common/Controls/AnimationControl.cs#L237

But I haven't experienced also and have no idea why it occurs and mitigates by commenting out that line.

Kagamia commented 1 year ago

@KENNYSOFT 'Invalidate' is overloaded for only used to draw the next frame.

I'm confused that the original Monogame GameForm have no memleak issue, and GraphicsControl memleak only occurs on specific environment, so what's the root cause here?

Kagamia commented 1 year ago

@KENNYSOFT For those who are glad to help us to improve WcR2, please provide more details such as

for Windows 7 sp1 and earlier, better to list all installed KB updates. Since we have no lightweight tools to diagnostics the memory leak, coredump file is also welcome. I believe it is caused by COM object leak.


edit: require more info

KENNYSOFT commented 1 year ago

image

I just got the screenshot from a user who reported—still waiting for more detailed information as mentioned.

memoday commented 1 year ago

does anyone find a solution to it? or any temporary solution for immediate use?

Kagamia commented 1 year ago

@memoday There's no user reported their system information so far, we have no clue how it is caused.

memoday commented 1 year ago

@Kagamia

and CPU if you needed

Please let me know if you need any more information Thanks

Kagamia commented 1 year ago

@memoday Thanks for your report.

Tried the same driver verison on my laptop (11.0.22621.963, GFX1050Ti) but can't repro, so it should only happen on very specific hardware and driver.

memoday commented 1 year ago

@Kagamia Thanks for your attempts

Do you have any more suggestions to it?

Or is there any tricks to run it properly? ex) running on VM or using memory optimizer

Kagamia commented 1 year ago

@memoday We don't have a workaround so far, or you can follow this comments but it will disable the image viewer control.

I see monogame have a hotfix update 3.8.1 this year, but it only targets .net6 Maybe we can bump to Net6 (or multi target build) to check if it is fixed? It is really a challenge.

memoday commented 1 year ago

@Kagamia Fortunately, I have solved the problem, but I still do not get how it fixed.

I tried the following commands on CMD

Im not sure if these solutions helped (maybe some drivers were updated while fixing the error) I can tell that hardware was not the problem

Kagamia commented 1 year ago

@memoday so we still don't know that which step actually help with the issue?

memoday commented 1 year ago

@Kagamia Sadly no, I have no idea here. This is so weird.

eikyu625 commented 1 year ago

发现使用管理员身份运行本程序可以解决此问题。

memoday commented 1 year ago

发现使用管理员身份运行本程序可以解决此问题。

Not really, it was my first solution to this issue

eikyu625 commented 1 year ago

发现使用管理员身份运行本程序可以解决此问题。

Not really, it was my first solution to this issue

But it solved the problem for me.It works fine now.

Kagamia commented 11 months ago

更新了一些代码,但是是面向于monogame 3.8.1的fix,不知道对目前版本有没有帮助。

eikyu625 commented 11 months ago

更新了一些代码,但是是面向于monogame 3.8.1的fix,不知道对目前版本有没有帮助。

测试了问题确实得到了解决,或许这个issue终于可以被关闭了。