• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Crash] Map crashes on init randomly

Antares

Spell Reviewer
Level 22
Joined
Dec 13, 2009
Messages
523
Hello,

I'm experiencing the issue that upon map init, the game crashes for some of the players in my map, but not for others (no desync, game closes itself). It also seems to be entirely unpredictable. In the first attempt, it will crash for players A and B, in the second it will crash for player C, but not for A and B, then in the third attempt it will work and we can play normally.

No idea where I should start searching for the cause of this. Has anyone experienced such an issue?

I'm like 70% sure it has to do something with the custom UI. Here is the map init UI code. Maybe it helps.

JASS:
function InitFrame takes nothing returns nothing

	local integer A
	local integer row
	local integer column
	local trigger trig
	
	//=============================================================================
	//Init
	//=============================================================================
	
	call BlzLoadTOCFile("war3mapImported\\Templates.toc")
	call BlzHideOriginFrames(true)
	call BlzFrameSetAllPoints(BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0), BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0))
	
	//Remove black rectangle at bottom of screen
	call BlzFrameSetVisible(BlzGetFrameByName("ConsoleUIBackdrop",0), false)
	
	//=============================================================================
	//Minimap
	//=============================================================================

	set minimapParent = BlzCreateFrameByType("BACKDROP", "minimapParent", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetAbsPoint( minimapParent , FRAMEPOINT_CENTER , 0.07925 , 0.07625 )
	call BlzFrameSetSize( minimapParent , 2*0.0715 , 2*0.0715 )
	call BlzFrameSetTexture( minimapParent , "MinimapBackdrop.blp" , 0 , true )
	call BlzFrameSetVisible( minimapParent , false )
	call BlzFrameSetLevel( minimapParent , 0 )
	
	call ExecuteFunc("VoteExit_Init")
	call ExecuteFunc("VoteConcede_Init")
	
	//=============================================================================
	//Replay compatibility
	//=============================================================================
	
	set A = 0
	loop
	exitwhen A > 11
		set commandButton[A] = BlzGetFrameByName( "CommandButton_" + I2S(A), 0)
		if GetHandleId(commandButton[A]) == 0 then
			call Location(0,0)
			set isReplay = true
		else
			set isReplay = false
		endif
		set A = A + 1
	endloop

	//=============================================================================
	//Hero Icon
	//=============================================================================

	set heroIconFrame = BlzCreateFrameByType("BACKDROP", "heroIconFrame", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetSize(heroIconFrame, 0.0385, 0.0385)
	call BlzFrameSetAbsPoint(heroIconFrame, FRAMEPOINT_TOPLEFT, 0.156, 0.1470)
	call BlzFrameSetVisible( heroIconFrame , false )
	call BlzFrameSetTexture( heroIconFrame , "ReplaceableTextures\\CommandButtons\\BTNBlackWithEdges.blp" , 0 , true )
	
	set heroIconFrameHover = BlzCreateFrameByType("FRAME" , "heroIconFrameHover" , heroIconFrame , "" , 0)
	call BlzFrameSetAllPoints( heroIconFrameHover , heroIconFrame )

	set heroIconFrameTooltip = BlzCreateFrame("BoxedText", heroIconFrameHover, 0, 0)
	call BlzFrameSetAbsPoint( heroIconFrameTooltip , FRAMEPOINT_BOTTOMRIGHT , 0.8 , 0.1625 )
	call BlzFrameSetTooltip( heroIconFrameHover , heroIconFrameTooltip )
	call BlzFrameSetSize( heroIconFrameTooltip , 0.29 , 0.0 ) //0.054
	set heroIconFrameTooltipTitle = BlzFrameGetChild( heroIconFrameTooltip,0)
	set heroIconFrameTooltipText = BlzFrameGetChild( heroIconFrameTooltip,1)
	
	//=============================================================================
	//Stats
	//=============================================================================

	set massFrame = BlzCreateFrameByType("TEXT", "massFrame", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetAbsPoint(massFrame, FRAMEPOINT_TOPLEFT, 0.157, 0.1048)
	call BlzFrameSetScale(massFrame, 0.92)
	call BlzFrameSetEnable(massFrame,false)

	set maxSpeedFrame = BlzCreateFrameByType("TEXT", "maxSpeedFrame", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetAbsPoint(maxSpeedFrame, FRAMEPOINT_TOPLEFT, 0.157, 0.0842)
	call BlzFrameSetScale(maxSpeedFrame, 0.92)
	call BlzFrameSetEnable(maxSpeedFrame,false)

	set accelerationFrame = BlzCreateFrameByType("TEXT", "accelerationFrame", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetAbsPoint(accelerationFrame, FRAMEPOINT_TOPLEFT, 0.157, 0.0633)
	call BlzFrameSetScale(accelerationFrame, 0.92)
	call BlzFrameSetEnable(accelerationFrame,false)

	set decelerationFrame = BlzCreateFrameByType("TEXT", "decelerationFrame", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetAbsPoint(decelerationFrame, FRAMEPOINT_TOPLEFT, 0.157, 0.0424)
	call BlzFrameSetScale(decelerationFrame, 0.92)
	call BlzFrameSetEnable(decelerationFrame,false)
	
	//=============================================================================
	//Minigame frames
	//=============================================================================

	set scoreFrame = BlzCreateFrameByType("TEXT", "scoreFrame", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetSize(scoreFrame, 0.2, 0.02)
	call BlzFrameSetAbsPoint(scoreFrame, FRAMEPOINT_CENTER, 0.4, 0.56625)
	call BlzFrameSetTextAlignment(scoreFrame , TEXT_JUSTIFY_MIDDLE , TEXT_JUSTIFY_CENTER)
	call BlzFrameSetScale(scoreFrame, 1.1)
	call BlzFrameSetEnable(scoreFrame,false)

	set timeFrame = BlzCreateFrameByType("TEXT", "timeFrame", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetSize(timeFrame, 0.075, 0.02)
	call BlzFrameSetAbsPoint(timeFrame, FRAMEPOINT_CENTER, 0.4015, 0.55)
	call BlzFrameSetTextAlignment(timeFrame , TEXT_JUSTIFY_MIDDLE , TEXT_JUSTIFY_CENTER)
	call BlzFrameSetScale(timeFrame, 1.1)
	call BlzFrameSetEnable(timeFrame,false)

	set medalFrame = BlzCreateFrameByType("TEXT", "medalFrame", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetSize(medalFrame, 0.075, 0.02)
	call BlzFrameSetAbsPoint(medalFrame, FRAMEPOINT_CENTER, 0.4015, 0.55)
	call BlzFrameSetTextAlignment(medalFrame , TEXT_JUSTIFY_MIDDLE , TEXT_JUSTIFY_CENTER)
	call BlzFrameSetScale(medalFrame, 1.1)
	call BlzFrameSetEnable(medalFrame,false)

	set reviveFrame = BlzCreateFrameByType("TEXT", "reviveFrame", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetSize(reviveFrame, 0.075, 0.02)
	call BlzFrameSetAbsPoint(reviveFrame, FRAMEPOINT_CENTER, 0.4, 0.0915)
	call BlzFrameSetVisible(reviveFrame , false)
	call BlzFrameSetTextAlignment(reviveFrame , TEXT_JUSTIFY_MIDDLE , TEXT_JUSTIFY_CENTER)
	call BlzFrameSetScale(reviveFrame, 2)

	set countdownFrame = BlzCreateFrameByType("TEXT", "countdownFrame", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetSize(countdownFrame, 0.2, 0.2)
	call BlzFrameSetAbsPoint(countdownFrame, FRAMEPOINT_CENTER, 0.4, 0.3)
	call BlzFrameSetVisible(countdownFrame , false)
	call BlzFrameSetTextAlignment(countdownFrame , TEXT_JUSTIFY_MIDDLE , TEXT_JUSTIFY_CENTER)
	call BlzFrameSetEnable(countdownFrame , false)
	
	//=============================================================================
	//Status bars
	//=============================================================================

	//Health Bar
	set statusBarFrame[0] = BlzCreateFrame("EscMenuControlBackdropTemplate", BlzFrameGetChild(BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),1), 0, 0)
	call BlzFrameSetAbsPoint(statusBarFrame[0], FRAMEPOINT_CENTER, 0.4, 0.1085)
	call BlzFrameSetSize(statusBarFrame[0], 0.12, 0.023)

	set statusBarFrame[1] = BlzCreateFrameByType("SIMPLESTATUSBAR", "", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetPoint(statusBarFrame[1], FRAMEPOINT_TOPLEFT, statusBarFrame[0], FRAMEPOINT_TOPLEFT, 0.005, -0.005)
	call BlzFrameSetPoint(statusBarFrame[1], FRAMEPOINT_BOTTOMRIGHT, statusBarFrame[0], FRAMEPOINT_BOTTOMRIGHT, -0.005, 0.005)
	call BlzFrameSetTexture(statusBarFrame[1], "herobar.blp", 0, true)
	call BlzFrameSetVertexColor(statusBarFrame[1], BlzConvertColor(255, 0, 255, 0))
	call BlzFrameSetMinMaxValue(statusBarFrame[1], 0, 1)

	set statusBarFrame[2] = BlzCreateFrameByType("TEXT", "healthBarText" , BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetAbsPoint( statusBarFrame[2] , FRAMEPOINT_CENTER , 0.4 , 0.1080 )
	call BlzFrameSetScale( statusBarFrame[2] , 1.1 )

	//Mana Bar
	set statusBarFrame[3] = BlzCreateFrame("EscMenuControlBackdropTemplate", BlzFrameGetChild(BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),1), 0, 0)
	call BlzFrameSetAbsPoint(statusBarFrame[3], FRAMEPOINT_CENTER, 0.4, 0.0920)
	call BlzFrameSetSize(statusBarFrame[3], 0.12, 0.023)

	set statusBarFrame[4] = BlzCreateFrameByType("SIMPLESTATUSBAR", "", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetPoint(statusBarFrame[4], FRAMEPOINT_TOPLEFT, statusBarFrame[3], FRAMEPOINT_TOPLEFT, 0.005, -0.005)
	call BlzFrameSetPoint(statusBarFrame[4], FRAMEPOINT_BOTTOMRIGHT, statusBarFrame[3], FRAMEPOINT_BOTTOMRIGHT, -0.005, 0.005)
	call BlzFrameSetTexture(statusBarFrame[4], "herobar.blp", 0, true)
	call BlzFrameSetVertexColor(statusBarFrame[4], BlzConvertColor(255, 50, 80, 255))
	call BlzFrameSetMinMaxValue(statusBarFrame[4], 0, 1)

	set statusBarFrame[5] = BlzCreateFrameByType("TEXT", "manaBarText" , BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetAbsPoint( statusBarFrame[5] , FRAMEPOINT_CENTER , 0.4 , 0.0915 )
	call BlzFrameSetScale( statusBarFrame[5] , 1.1 )
	
	//Breath bar
	set statusBarFrame[6] = BlzCreateFrame("EscMenuControlBackdropTemplate", BlzFrameGetChild(BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),1), 0, 0)
	call BlzFrameSetAbsPoint(statusBarFrame[6], FRAMEPOINT_CENTER, 0.4, 0.1255)
	call BlzFrameSetSize(statusBarFrame[6], 0.12, 0.023)
	call BlzFrameSetAlpha(statusBarFrame[6] , 0)

	set statusBarFrame[7] = BlzCreateFrameByType("SIMPLESTATUSBAR", "", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetPoint(statusBarFrame[7], FRAMEPOINT_TOPLEFT, statusBarFrame[6], FRAMEPOINT_TOPLEFT, 0.005, -0.005)
	call BlzFrameSetPoint(statusBarFrame[7], FRAMEPOINT_BOTTOMRIGHT, statusBarFrame[6], FRAMEPOINT_BOTTOMRIGHT, -0.005, 0.005)
	call BlzFrameSetTexture(statusBarFrame[7], "herobar.blp", 0, true)
	call BlzFrameSetVertexColor(statusBarFrame[7], BlzConvertColor(255, 140, 200, 255))
	call BlzFrameSetMinMaxValue(statusBarFrame[7], 0, 1)
	call BlzFrameSetAlpha(statusBarFrame[7] , 0)

	set statusBarFrame[8] = BlzCreateFrameByType("TEXT", "breathBarText" , BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
	call BlzFrameSetAbsPoint( statusBarFrame[8] , FRAMEPOINT_CENTER , 0.4 , 0.125 )
	call BlzFrameSetScale( statusBarFrame[8] , 1.1 )
	call BlzFrameSetAlpha(statusBarFrame[8] , 0)
	call BlzFrameSetText( statusBarFrame[8] , "Breath" )

	set A = 0
	loop
	exitwhen A > 8
		call BlzFrameSetVisible( statusBarFrame[A] , false )
		set A = A + 1
	endloop

	call TimerStart( statusBarUpdateTimer , 0.05 , true , function StatusBarUpdate )
	
	//=============================================================================
	//Combat log
	//=============================================================================

	set A = 0
	loop
	exitwhen A > 6
		set logFrame[A] = BlzCreateFrameByType("TEXT", "logFrame" + I2S(A), BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
		call BlzFrameSetSize(logFrame[A], 0.305, 0.013)
		call BlzFrameSetAbsPoint(logFrame[A], FRAMEPOINT_BOTTOMLEFT, 0.485, 0.005 + 0.013*A)
		call BlzFrameSetTextAlignment(logFrame[A] , TEXT_JUSTIFY_BOTTOM , TEXT_JUSTIFY_LEFT)
		call BlzFrameSetVisible( logFrame[A] , false )
		call BlzFrameSetEnable(logFrame[A],false)
		set logFrameTimer[A] = CreateTimer()
		call SaveInteger( hashTable , GetHandleId(logFrameTimer[A]) , 1 , A )
		set A = A + 1
	endloop
	
	//=============================================================================
	//Text messages
	//=============================================================================
	
	set A = 0
	loop
	exitwhen A > 4
		set textMessageFrame[A] = BlzCreateFrame("TextMessage", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
		set textMessageText[A] = BlzFrameGetChild( textMessageFrame[A],0)
		call BlzFrameSetSize(textMessageText[A], 0.25, 0)
		call BlzFrameSetScale(textMessageText[A] , 1.25 )
		call BlzFrameSetAbsPoint(textMessageFrame[A], FRAMEPOINT_BOTTOMLEFT, TEXT_MESSAGE_X_POSITION, TEXT_MESSAGE_Y_POSITION)
		call BlzFrameSetTextAlignment(textMessageText[A] , TEXT_JUSTIFY_BOTTOM , TEXT_JUSTIFY_CENTER)
		call BlzFrameSetVisible( textMessageFrame[A] , false )
		call BlzFrameSetEnable(textMessageFrame[A],false)
		call BlzFrameSetEnable(textMessageText[A],false)
		call BlzFrameSetText(textMessageText[A],"")
		set A = A + 1
	endloop
	
	//=============================================================================
	//Particle counter
	//=============================================================================
	
	set A = 1
	loop
	exitwhen A > 4
		set particleBackdropFrame[A] = BlzCreateFrameByType("BACKDROP", "particleBackdropFrame" + I2S(A) , BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
		call BlzFrameSetSize(particleBackdropFrame[A], 0.019, 0.019)
		if not isReplay then
			call BlzFrameSetPoint(particleBackdropFrame[A], FRAMEPOINT_BOTTOMRIGHT, commandButton[A-1] , FRAMEPOINT_BOTTOMRIGHT , 0, 0)
		else
			call BlzFrameSetAbsPoint(particleBackdropFrame[A], FRAMEPOINT_BOTTOMRIGHT , -1, -1)
		endif
		call BlzFrameSetTexture( particleBackdropFrame[A] , "UI\\Widgets\\Console\\Human\\CommandButton\\human-button-lvls-overlay.blp" , 0 , true )
		call BlzFrameSetVisible( particleBackdropFrame[A] , false )
		call BlzFrameSetEnable( particleBackdropFrame[A] , false )
		
		set particleNumberFrame[A] = BlzCreateFrameByType("TEXT", "particleNumberFrame" + I2S(A), BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
		call BlzFrameSetSize(particleNumberFrame[A], 0.019, 0.019)
		if not isReplay then
			call BlzFrameSetPoint(particleNumberFrame[A], FRAMEPOINT_BOTTOMRIGHT, commandButton[A-1] , FRAMEPOINT_BOTTOMRIGHT , -0.001, 0)
		else
			call BlzFrameSetAbsPoint(particleNumberFrame[A], FRAMEPOINT_BOTTOMRIGHT , -1, -1)
		endif
		call BlzFrameSetText( particleNumberFrame[A] , "10" )
		call BlzFrameSetTextAlignment( particleNumberFrame[A] , TEXT_JUSTIFY_MIDDLE , TEXT_JUSTIFY_CENTER )
		call BlzFrameSetVisible( particleNumberFrame[A] , false )
		call BlzFrameSetEnable( particleNumberFrame[A] , false )

		set A = A + 1
	endloop
	
	if not isReplay then
		set A = 8
		loop
		exitwhen A > 11
			call BlzFrameSetVisible( commandButton[A] , false )
			set A = A + 1
		endloop
	endif
endfunction
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
Try to create the UI using an Elapsed Game Time event rather than Map Initialization. There's also some desyncs related to frames where you need to reference the frame globally once before it becomes safe to use locally. Tasyen talks about it in his UI thread.
 

Antares

Spell Reviewer
Level 22
Joined
Dec 13, 2009
Messages
523
Thanks, I moved all the UI stuff to elapsed time 0.0 seconds instead of map initialization. Should that work?

The second issue you mentioned you said is causing desyncs. Since the game crashed but the other players stayed in the game, that appears to be a different issue. But desyncs can also cause the game to crash...
 

Antares

Spell Reviewer
Level 22
Joined
Dec 13, 2009
Messages
523
Try to create the UI using an Elapsed Game Time event rather than Map Initialization. There's also some desyncs related to frames where you need to reference the frame globally once before it becomes safe to use locally. Tasyen talks about it in his UI thread.
Sadly, it didn't fix the problem. I moved almost everything away from map initialization (except for setting up triggers etc. in initializers), but it still crashes some of the time. But it seems to only happen when one of the players in my playgroup is in the lobby (!?). It's weird.

I use:
JASS:
call TriggerRegisterTimerEventSingle( trig, 0.0 )
for the other stuff now.
 
Top