View Issue Details

IDProjectCategoryView StatusLast Update
0002446FSSCPgraphicspublic2011-05-30 18:48
ReporterFury Assigned ToThe_E  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.13 
Fixed in Version3.6.13 
Summary0002446: Particle generation when game is paused
DescriptionIf you pause the game by pressing either esc, pause or alt-tabbing (same as pause) while FSO is generating particles, resuming the game will take really long time by seemingly freezing FSO to halt until it slowly starts recovering from really low fps to normal fps. This problem can be replicated by either tabling options or any script that produces particles.

This problem isn't new and has been around since at least 3.6.11.

I suggest trying this script to trigger the problem.
http://www.hard-light.net/forums/index.php?topic=76406
TagsNo tags attached.

Activities

Fury

2011-05-29 16:50

reporter   ~0012695

Forgot to say that the recovery from pause is slower the more particles were generated when game was paused.

Fury

2011-05-30 16:38

reporter   ~0012699

I further tested the pause problem and I have to correct myself. This doesn't occur with pause, only with esc menu.

You see, if you press pause, you get Got event GS_EVENT_PAUSE_GAME (6) in state GS_STATE_GAME_PLAY (2)
If you press it again, you get Got event GS_EVENT_PREVIOUS_STATE (7) in state GS_STATE_GAME_PAUSED (3)

But if you press esc instead, game state does not change. I suspect this means all scripts are left in running state and when you resume the game, everything that your scripts have been working while esc menu was on, is getting thrown in at once. No idea at this time if this is limited to scripts or whether it does affect tabled particle generation too.

2011-05-30 17:35

 

mantis2446-patch.patch (2,340 bytes)   
Index: code/graphics/2d.cpp
===================================================================
--- code/graphics/2d.cpp	(revision 7218)
+++ code/graphics/2d.cpp	(working copy)
@@ -31,6 +31,7 @@
 #include "graphics/grbatch.h"
 #include "parse/scripting.h"
 #include "gamesequence/gamesequence.h"	//WMC - for scripting hooks in gr_flip()
+#include "Io/keycontrol.h" // m!m
 
 
 #if defined(SCP_UNIX) && !defined(__APPLE__)
@@ -1469,12 +1470,16 @@
 
 void gr_flip()
 {
-	//WMC - Evaluate global hook if not override.
-	Script_system.RunBytecode(Script_globalhook);
-	//WMC - Do conditional hooks. Yippee!
-	Script_system.RunCondition(CHA_ONFRAME);
-	//WMC - Do scripting reset stuff
-	Script_system.EndFrame();
+	// m!m avoid running CHA_ONFRAME when the "Quit mission" popup is shown. See mantis 2446 for reference
+	if (!quit_mission_popup_shown)
+	{
+		//WMC - Evaluate global hook if not override.
+		Script_system.RunBytecode(Script_globalhook);
+		//WMC - Do conditional hooks. Yippee!
+		Script_system.RunCondition(CHA_ONFRAME);
+		//WMC - Do scripting reset stuff
+		Script_system.EndFrame();
+	}
 
 	gr_screen.gf_flip();
 }
Index: code/io/keycontrol.cpp
===================================================================
--- code/io/keycontrol.cpp	(revision 7218)
+++ code/io/keycontrol.cpp	(working copy)
@@ -88,6 +88,7 @@
 									  // 666)6=N79+Z45=BE0e
 int Tool_enabled = 0;
 bool Perspective_locked=false;
+bool quit_mission_popup_shown = false;
 
 	/*
 #else 
@@ -1404,6 +1405,8 @@
 		game_stop_looped_sounds();
 		snd_stop_all();
 
+		quit_mission_popup_shown = true;
+
 		pf_flags = PF_BODY_BIG | PF_USE_AFFIRMATIVE_ICON | PF_USE_NEGATIVE_ICON;
 		choice = popup(pf_flags, 3, POPUP_NO, XSTR( "&Yes, Quit", 28), XSTR( "Yes, &Restart", 29), XSTR( "Do you really want to end the mission?", 30));
 
@@ -1431,6 +1434,7 @@
 		default:
 			break;  // do nothing
 		}
+		quit_mission_popup_shown = false;
 
 		game_start_time();
 		game_flush();
Index: code/io/keycontrol.h
===================================================================
--- code/io/keycontrol.h	(revision 7218)
+++ code/io/keycontrol.h	(working copy)
@@ -21,6 +21,8 @@
 extern int Dead_key_set_size;
 extern bool Perspective_locked;
 
+extern bool quit_mission_popup_shown;
+
 typedef struct button_info
 {
 	int status[NUM_BUTTON_FIELDS];
mantis2446-patch.patch (2,340 bytes)   

m_m

2011-05-30 17:36

developer   ~0012700

I traced the code responsible for the popup and it calls gr_flip() which causes the CHA_ONFRAME scripting hook to be run. Disabling this hook as long as the popup is shown fixes the problem.
Patch is attached.

The_E

2011-05-30 18:47

administrator   ~0012701

Patch committed to trunk in revision 7219

Issue History

Date Modified Username Field Change
2011-05-29 16:49 Fury New Issue
2011-05-29 16:50 Fury Note Added: 0012695
2011-05-30 16:38 Fury Note Added: 0012699
2011-05-30 17:35 m_m File Added: mantis2446-patch.patch
2011-05-30 17:36 m_m Note Added: 0012700
2011-05-30 18:47 The_E Note Added: 0012701
2011-05-30 18:48 The_E Status new => resolved
2011-05-30 18:48 The_E Fixed in Version => 3.6.13
2011-05-30 18:48 The_E Resolution open => fixed
2011-05-30 18:48 The_E Assigned To => The_E