Skip to content

Fix unexpected crash from background music #675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2025

Conversation

SadPencil
Copy link
Member

@SadPencil SadPencil commented Mar 17, 2025

To prevent crash like this one:

(in this log file, please subtract line numbers of MainMenu.cs by 12 when viewing on the latest commit af7e44f)

12.03. 12:01:55.672    GameProcessLogic: Process started.
12.03. 12:01:56.402    Waiting for qres.dat or Syringe.exe to exit.
12.03. 12:11:17.215    GameProcessLogic: Process exited.
12.03. 12:11:21.195    KABOOOOOOM!!! Info:
12.03. 12:11:21.195    Type: System.Reflection.TargetInvocationException
12.03. 12:11:21.195    Message: Exception has been thrown by the target of an invocation.
12.03. 12:11:22.055    Source: mscorlib
12.03. 12:11:22.055    TargetSite.Name: InvokeMethod
12.03. 12:11:22.105    Stacktrace:    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at Rampastring.XNAUI.XNAControls.XNAControl.Update(GameTime gameTime)
   at Rampastring.XNAUI.XNAControls.XNAPanel.Update(GameTime gameTime)
   at DTAClient.DXGUI.Generic.MainMenu.Update(GameTime gameTime) in DXMainClient\DXGUI\Generic\MainMenu.cs:line 925
   at Rampastring.XNAUI.WindowManager.Update(GameTime gameTime)
   at Microsoft.Xna.Framework.Game.SortingFilteringCollection`1.ForEachFilteredItem[TUserData](Action`2 action, TUserData userData)
   at Microsoft.Xna.Framework.Game.DoUpdate(GameTime gameTime)
   at Microsoft.Xna.Framework.Game.Tick()
   at MonoGame.Framework.WinFormsGameWindow.TickOnIdle(Object sender, EventArgs e)
   at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at MonoGame.Framework.WinFormsGameWindow.RunLoop()
   at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
   at DTAClient.Startup.Execute() in DXMainClient\Startup.cs:line 159
   at DTAClient.PreStartup.Initialize(StartupParams parameters) in DXMainClient\PreStartup.cs:line 218
12.03. 12:11:22.105    InnerException info:
12.03. 12:11:22.105    Type: SharpDX.SharpDXException
12.03. 12:11:22.105    Message: HRESULT: [0xC00D4E86], Module: [Unknown], ApiCode: [Unknown/Unknown], Message: Unknown
12.03. 12:11:22.165    Source: SharpDX
12.03. 12:11:22.165    TargetSite.Name: CheckError
12.03. 12:11:22.185    Stacktrace:    at SharpDX.Result.CheckError()
   at SharpDX.MediaFoundation.AudioStreamVolume.GetChannelCount(Int32& dwCountRef)
   at Microsoft.Xna.Framework.Media.MediaPlayer.SetChannelVolumes()
   at Microsoft.Xna.Framework.Media.MediaPlayer.set_Volume(Single value)
   at DTAClient.DXGUI.Generic.MainMenu.PlayMusic() in DXMainClient\DXGUI\Generic\MainMenu.cs:line 948
   at DTAClient.DXGUI.Generic.MainMenu.HandleGameProcessExited() in DXMainClient\DXGUI\Generic\MainMenu.cs:line 908

Copy link

Nightly build for this pull request:

@MahBoiDeveloper
Copy link
Contributor

Can you describe how to repeat this bug before your bugfix?

@11EJDE11
Copy link
Contributor

Probably this on Discord.

image

@SadPencil
Copy link
Member Author

Can you describe how to repeat this bug before your bugfix?

Can't. A buggy machine maybe, but worth a fix in codes.

@SadPencil
Copy link
Member Author

SadPencil commented May 4, 2025

Probably this on Discord.

image

No. The screenshot you mentioned is another issue caused by handling cross-platform BGM support. Summarized in #693

Copy link
Member

@Metadorius Metadorius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure of the fix method exactly but let's try.

@Metadorius Metadorius merged commit 1d01897 into CnCNet:develop May 4, 2025
3 checks passed
@SadPencil SadPencil deleted the fix-crash-on-background-music branch May 4, 2025 10:59
Metadorius added a commit that referenced this pull request May 10, 2025
* Fix L10N for message boxes in `GameProcessLogic` class (#679)

* Fix L10N for `ErrorLaunchQresText`

* Add L10N to `INIPreprocessingNotCompleteTitle`

* Replace `ErrorLaunchGameEngine` and `ErrorLaunchQres` with `ErrorLaunching`

* Update copyright years

* Attempt to fix game room desync by having players confirm game start (#680)

* Fix game room desync by having players confirm game start

* Fix style

* Fix crash when the player themself is not in the player list (#684)

* Fix potential crash when client map name is not a valid Win32 file name (#691)

* Fix crash when client try to save map file with map name that contains special symbols

* Rename method

Co-authored-by: SadPencil <[email protected]>

* Add more checks and commentaries

* Use a HashSet for a  case-insensitive comparison

* Update ClientCore/Extensions/StringExtensions.cs

Co-authored-by: Kerbiter <[email protected]>

* Update StringExtensions.cs

* Move patch to `GetMapFileName`

---------

Co-authored-by: SadPencil <[email protected]>
Co-authored-by: Kerbiter <[email protected]>

* Loaded game lobby fixups (#689)

* Remove change tunnel option for non-hosts

* Disable broadcasting games for non hosts

* Fix stuck joining game

* Block messages from blocked users

* Fix crash when accepting invite

* Delay loading statistics listbox until StatisticsWindow is initialized and visible (#685)

* Fix unexpected crash from background music (#675)

* Fix crash when starting game with null map (#667)

* Fix crash on launching game with no map

* Make player return from game

* Add GameStartAborted and ResetGameState

* Unified client build (#688)

* Move compiler checks for TS, YR, Ares to runtime

* Remove Ares, TS, YR constants from configs

* Move `ClientType` to the `ClientCore/Enums/ClientType.cs` and `ParseEnum` to the `ClientCore/Extenstions/StringExtensions.cs`

* Add default branch for switch

* Add clearing script

* Remove `using SharpDX.Direct3D9` in `StringExtentsions.cs`

* Fix compilation script

* Experimental delete of broken configurations through Rider

* Add `cd /d %~dp0` in clearing script

* Remove extra spaces in clearing script

* Commit edits by VS2022

* Add comment about why Release builds should be failed on the run

* Add `ClientGameType` key mentioning

* Remove `None` enum option in the `ClientType` enum to delete undefined behaviour in future

* Update info about builds in readme

* Update build documentation

* Fix typo in image path

* Fix typo

* Fix typo in the comment

* Update text in Migration.md

* Update text in Build.md

* Update text in Readme.md

Co-authored-by: SadPencil <[email protected]>

* Adjustment CI/CD

Co-authored-by: SadPencil <[email protected]>

* Fix path to zip artifacts

* Update .github/workflows/build.yml

Co-authored-by: Mozi <[email protected]>

* Update ClientCore/Enums/ClientType.cs

Co-authored-by: Kerbiter <[email protected]>

* Replace "TS" with "nameof(ClientType.TS)"

Co-authored-by: Kerbiter <[email protected]>

* Restore option to run powershell script in CI/CD

---------

Co-authored-by: SadPencil <[email protected]>
Co-authored-by: Mozi <[email protected]>
Co-authored-by: Kerbiter <[email protected]>

* Update Rampastring.XNAUI to add support for text selection in textboxes (#694)

Co-authored-by: Rami Pasanen <[email protected]>

* Upgrade SixLabors.ImageSharp to 2.1.10

* Migrate XNAUI changes

* Fix crash when the desktop resolution is too small (#692)

* Fix crash when the desktop resolution is too small

* Refactor recommended resolutions methods

* Address review comments

* Address review comments

* Make ScreenResolution file nullable

* Update DTAConfig/ScreenResolution.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* Remove MainMenuDarkeningPanel (#511)

* Delete MainMenuDarkeningPanel.cs

* Remove MainMenuDarkeningPanel

* Update TODOs in MainMenu.cs

* Add Steamworks SDK (#595)

* Add steam sdk

* Switch to Facepunch package, add option to disable steam in client

* Extract steamapi native library from Facepunch.Steamworks package

* Add steam dlls to common assemblies

* Upgrade to modified Facepunch.Steamworks 2.4.1

which is released in .NET Standard 2.0

* Grant additional permission under GPLv3

* Update DXMainClient/Startup.cs

Co-authored-by: mah_boi <[email protected]>

---------

Co-authored-by: SadPencil <[email protected]>
Co-authored-by: mah_boi <[email protected]>

* Build release via CI (#686)

* Build release via CI

* Update release-build.yml

* Update release-build.yml

* Update release-build.yml

* Update release-build.yml

* Update release-build.yml

* Apply suggestions from code review

---------

Co-authored-by: Kerbiter <[email protected]>

* Add configurable MapFileExtension to ClientDefinitions.ini (#690)

* adding MapExtension=.map to ClientDefinitions to support Dune2000 .ini map filetype integration

* Update DXMainClient/Domain/Multiplayer/CnCNet/MapSharer.cs

Co-authored-by: mah_boi <[email protected]>

* Update DXMainClient/Domain/Multiplayer/MapLoader.cs

Co-authored-by: mah_boi <[email protected]>

* removing requirement of . in ClientDefinition for MapExtension

* Adjust the code a bit to conform with existing keys

* Revert wrong change that adds extension to partial filename

---------

Co-authored-by: mah_boi <[email protected]>
Co-authored-by: Metadorius <[email protected]>

* Unify CI names

* Remove unnecessary UniversalGL binaries (#696)

* Suppress the warning on introducing a manifest file

* Disable chat message audio when game is running (#658)

* Disable message received audio when game is running

* Add setting StopGameLobbyMessageAudio
Add UI constants to AudioOptionsPanel

* Minor fixups

* Add asserts on whether a map file path ends with the extension

* Remove unnecessary GL binaries

* Improved background music support (#698)

* Import MonoGame.Framework.Content.Pipeline

* Update MainMenu.cs

* Delete MainMenuTheme.xnb

* Revert "Import MonoGame.Framework.Content.Pipeline"

This reverts commit a643011.

* Update MainMenu.cs

* Update MainMenu.cs

* Update MainMenu.cs

* Update MainMenu.cs

* Update MainMenu.cs

* Revert "Delete MainMenuTheme.xnb"

This reverts commit a50c288.

* Remove default value of ClientGameType (#697)

* Remove default value of ClientGameType

* Update ClientConfiguration.cs

* Update Migration-INI.md

* Fix untranslated `ShowTunnelSelectionWindow` text caption (#701)

* Update nuget dependencies  (#699)

* Update DiscordRichPresence

* Update GitVersion.MsBuild

* Update OpenMcdf

* Update System.Memory

* Update System.Threading.Tasks.Extensions

* Update transitive packages System.Private.Uri from vulnerable version

* Update transitive packages System.Text.Json from vulnerable version

* Update DXMainClient.csproj

* Revert "Update GitVersion.MsBuild"

This reverts commit ea2c2eb.

* Update Polyfill

* Downgrade Polyfill to 6.14.0

* Update Rampastring.XNAUI to version 2.7.7 (#702)

Co-authored-by: Metadorius <[email protected]>

* Use correct property for clearing items (#703)

* Fix `spawnmap.ini` encoding while creating (#704)

* Revert partial changes in the `spawnmap.ini` encoding change

* Upgrade XNAUI to 2.7.8 (#700)

* Fix objects naming in OptionsPanel (#705)

---------

Co-authored-by: mah_boi <[email protected]>
Co-authored-by: 11EJDE11 <[email protected]>
Co-authored-by: Kerbiter <[email protected]>
Co-authored-by: Mozi <[email protected]>
Co-authored-by: Rami Pasanen <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Grant Bartlett <[email protected]>
Co-authored-by: Daniel "Danku" McMahon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants