Elvas Tower: Open Rails Monogame crash - Elvas Tower

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Open Rails Monogame crash Rate Topic: -----

#1 User is offline   jpmackay 

  • Conductor
  • Group: Status: R.I.P. or just Retired
  • Posts: 408
  • Joined: 11-March 08
  • Gender:Male
  • Country:

Posted 22 May 2019 - 08:02 AM

I am not sure what is exactly the problem with the program of Open Rails Monogame on my desktop. I am using the latest version of OR Monogame. While the player train is waiting at red signal after about 15 minutes of travelling from the yard. I see there are few flashing on my desktop screen while running in OR Monogame. My desktop is HP Omen #870-119 with ZOTAC Geforce GTX 1050TI 4Gb and the operating system is Windows 10 Pro with all updates to this date of today. Anyway I am enclosing the log.txt file for anyone who want to look at to see what is the actual problem with this.

Thank you,

John

Attached File(s)



#2 User is online   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 7,010
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 22 May 2019 - 11:56 PM

Hi John,
is this occurring in a specific activity at a specific point, or is this occurring in further circumstances?

#3 User is offline   jpmackay 

  • Conductor
  • Group: Status: R.I.P. or just Retired
  • Posts: 408
  • Joined: 11-March 08
  • Gender:Male
  • Country:

Posted 23 May 2019 - 07:04 AM

Hi Carlos,

The route is cnbalav2 1.2 (the latest update of this route) and the activity that I ran is cn_451 and the train consist is cn_a45131. Hope that you need the information from me that you asked for.

Thank you,

John

#4 User is offline   jpmackay 

  • Conductor
  • Group: Status: R.I.P. or just Retired
  • Posts: 408
  • Joined: 11-March 08
  • Gender:Male
  • Country:

Posted 27 May 2019 - 02:27 PM

Did you find anything with this log file?

John

#5 User is online   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 7,010
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 27 May 2019 - 11:41 PM

This is a practically impossible problem to solve for me, sorry:
1) It's a graphics problem and I'm not expert in graphics
2) The crash doesn't occur within OR; it occurs within the MonoGame library
3) I can't re-create the problem because I don't have the route.

#6 User is offline   roeter 

  • Vice President
  • Group: Status: Elite Member
  • Posts: 2,426
  • Joined: 25-October 11
  • Gender:Male
  • Country:

Posted 28 May 2019 - 01:20 AM

This problem reminds of a more or less similar problem which occured on my system with some regularity some years ago. That concerned a crash in XNA, also through an invalid index. In that case, the problem occured in EndDraw, rather than Draw.

I could not sort the problem, but avoided the program crash using the following patch (in game.cs) :

        [ThreadName("Render")]
        protected override void EndDraw()
        {
            try
            {
                RenderProcess.EndDraw();
                base.EndDraw();
            }
            catch (Exception e)
            {
                Program.Simulator.Confirmer.Message(ConfirmLevel.Information, "Render : " + e.Message);
            }
        }


I set the confirmer message so I could keep some trace of how often the problem occured.
Something similar could be tried here. You will loose a frame, but the program will continue.

Regards,
Rob Roeterdink

#7 User is online   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 7,010
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 28 May 2019 - 08:35 AM

Thanks Rob,
that's an idea in effect. I can add that in next OR NewYear MG version, together with a further message containing some parameter to check.

John,
is the problem repeatable? That is, if you run again the activity, you get the same problem at the same point?

#8 User is offline   jpmackay 

  • Conductor
  • Group: Status: R.I.P. or just Retired
  • Posts: 408
  • Joined: 11-March 08
  • Gender:Male
  • Country:

Posted 28 May 2019 - 11:50 AM

Hi Carlos,

I have not try to run again but will do shortly to see if that happen again or not. As far as I know that this is not a repeatable problem.

Thank you for your time to reply.

John

#9 User is online   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 7,010
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 29 May 2019 - 09:43 AM

I believe I have found the (theoric) reason of the crash; there seems to be a problem on thread safety.
Here is the code that crashed (within the DrawIndexedPrimitives call):
                if (FirstActiveParticle < FirstFreeParticle)
                {
                    var numParticles = FirstFreeParticle - FirstActiveParticle;
                    graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, FirstActiveParticle * VerticiesPerParticle, numParticles * VerticiesPerParticle, FirstActiveParticle * IndiciesPerParticle, numParticles * PrimitivesPerParticle);
                }

This code is executed in the Render Process.
However both FirstFreeParticle and FirstActiveParticle are updated in the Updater Process, and in particular FirstFreeParticle is periodically subject to a modulo (%) operation that reduces it. So, if the Updater Process reduces FirstFreeParticle after the if clause in the Render Process, numParticles becomes negative, and I assume that DrawIndexedPrimitives could not like negative parameters...
A rough solution conld be to test numParticles before the call, and skip the draw call if it is negative. In fact the subsequent lines after the if block are
              else
                {
                    var numParticlesAtEnd = MaxParticles - FirstActiveParticle;
                    if (numParticlesAtEnd > 0)
                        graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, FirstActiveParticle * VerticiesPerParticle, numParticlesAtEnd * VerticiesPerParticle, FirstActiveParticle * IndiciesPerParticle, numParticlesAtEnd * PrimitivesPerParticle);
                    if (FirstFreeParticle > 0)
                        graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, FirstFreeParticle * VerticiesPerParticle, 0, FirstFreeParticle * PrimitivesPerParticle);
                }

and that else block contains a check for numParticlesAtEnd > 0.

So, John, you don't need to run the activity again. You simply were misfortunate... but your post was very useful.
If there aren't particular comments from the IT gurus, I'll implement this in next release of OR NewYear MG.

#10 User is offline   James Ross 

  • Open Rails Developer
  • Group: Status: Elite Member
  • Posts: 5,491
  • Joined: 30-June 10
  • Gender:Not Telling
  • Simulator:Open Rails
  • Country:

Posted 30 May 2019 - 12:18 PM

View PostCsantucci, on 29 May 2019 - 09:43 AM, said:

This code is executed in the Render Process.
However both FirstFreeParticle and FirstActiveParticle are updated in the Updater Process, and in particular FirstFreeParticle is periodically subject to a modulo (%) operation that reduces it. So, if the Updater Process reduces FirstFreeParticle after the if clause in the Render Process, numParticles becomes negative, and I assume that DrawIndexedPrimitives could not like negative parameters...
A rough solution conld be to test numParticles before the call, and skip the draw call if it is negative. In fact the subsequent lines after the if block are

Yup, I suspect you're correct. This code is a bit racy, so either put both fields into local variables before the if, or check numParticles before the draw call.

View PostCsantucci, on 29 May 2019 - 09:43 AM, said:

If there aren't particular comments from the IT gurus, I'll implement this in next release of OR NewYear MG.

I hope this doesn't mean you're going to neglect the official version, and instead are simply testing the fix out in NewYear MG first. :)

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users