Threadsafe -> crash when Alt-Tab

All bugs related to the 3D engine
User avatar
STARGÅTE
Addict
Addict
Posts: 2084
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Threadsafe -> crash when Alt-Tab

Post by STARGÅTE »

Hi,

If I were the thread-safe mode for the Exe on, get this code is always an error in the debugger and when I wrote this off then a WIN-error when I use the ALT-TAB to go out screen, wants one could tell me why?
[ERROR] FlipBuffers()
[ERROR] Invalid memory access. (read error at address 64)

Code: Select all

InitSprite() 
InitSprite3D() 
InitKeyboard() 
InitMouse() 

OpenScreen(1024, 768, 32, "Screen") 
  
 CreateSprite(1,64,64, #PB_Sprite_Texture) 
 CreateSprite3D(1, 1) 
  
Repeat 

 FlipBuffers() 
 If IsScreenActive() 
  
  ClearScreen(0) 
  
  Start3D() 
   DisplaySprite3D(1,64,64) 
  Stop3D() 
   
  StartDrawing(ScreenOutput()) 
   DrawingMode(1) 
   DrawText(0,0,"Test", $FFFFFF) 
  StopDrawing() 
  
  ExamineMouse() 

  ExamineKeyboard() 
  If KeyboardPushed(#PB_Key_Escape) : End : EndIf 

 EndIf 


ForEver
My System:

Win XP SP3
PB 4.30 x86
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Isn't this the same as this one?
http://www.purebasic.fr/english/viewtopic.php?t=28676

People reported that as fixed with beta5. Is it still happening ?
quidquid Latine dictum sit altum videtur
User avatar
STARGÅTE
Addict
Addict
Posts: 2084
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Post by STARGÅTE »

No, it is not the same.
My code above crashes only when I thread-safe enabled and press Alt-Tab.
Without thread-safe, he runs without any problems.

I have just been discovered that was at the Sprite is, the code can thus be shortened:

Code: Select all

InitSprite() 
InitKeyboard() 

OpenScreen(1024, 768, 32, "Screen") 
  
 CreateSprite(1,64,64) 
  
Repeat 

 ClearScreen($808080) 
  DisplaySprite(1,64,64) 
 FlipBuffers() 
 
 ExamineKeyboard() 

Until KeyboardPushed(#PB_Key_Escape)
Alt-Tab with Thread-Safe --> crash at FlipBuffers, or win-error without Debugger
Alt-Tab without Thread-Safe --> run
User avatar
STARGÅTE
Addict
Addict
Posts: 2084
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Threadsafe -> crash when Alt-Tab

Post by STARGÅTE »

The problem still exists in 4.4 B3, can anyone confirm
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
gnasen
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Sep 24, 2008 12:21 am

Re: Threadsafe -> crash when Alt-Tab

Post by gnasen »

same here
pb 5.11
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Threadsafe -> crash when Alt-Tab

Post by netmaestro »

Same here. IsScreenActive() should help imho, but doesn't.
BERESHEIT
User avatar
STARGÅTE
Addict
Addict
Posts: 2084
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Threadsafe -> crash when Alt-Tab

Post by STARGÅTE »

The problem has changed now, the program no longer crashes, but that I shall return no more into the screen!
And the program freezes!
No Debug-Output, No Error!

And even when the Threadsafe!

Here my Code:

Code: Select all

InitSprite()
InitSprite3D()
InitKeyboard()

ExamineDesktops() 
OpenScreen(DesktopWidth(0), DesktopHeight(0), 32, "Screen")
 
 CreateSprite(1,64,64, #PB_Sprite_Texture)
 CreateSprite3D(1, 1)
 
Repeat

 Delay(10)

 FlipBuffers()
 If IsScreenActive()
 
  ClearScreen(0)
 
  Start3D()
   DisplaySprite3D(1,64,64)
  Stop3D()
  
  StartDrawing(ScreenOutput())
   DrawingMode(1)
   DrawText(0,0,"Test", $FFFFFF)
  StopDrawing()

 EndIf
 
 ExamineKeyboard()
 If KeyboardPushed(#PB_Key_Escape) : End : EndIf

ForEver
What am I doing wrong?

SystemDatas:
WINDOWS XP (SP3), 1,8GHz P4, ATI - RADEON 9700, PB 4.40
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Threadsafe -> crash when Alt-Tab

Post by luis »

STARGÅTE wrote: And the program freezes!
Actually it doesn't freeze, fails to restore the screen mode when switching back to it, but if you press escape the program quit nicely as expected.

Don't know what's wrong with your code, if anything is wrong. I don't have much experience with the directx part of pb, but looking at the docs it's seem to me your code should be ok.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Threadsafe -> crash when Alt-Tab

Post by luis »

Using directx7 as subsystem it works, so it has something to do with the directx9 subsystem I suppose (now enabled by default on 4.40).
"Have you tried turning it off and on again ?"
A little PureBasic review
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: Threadsafe -> crash when Alt-Tab

Post by PMV »

Just removed the Sprite3D calles to test if the behavior has
changed with the latest version (v5.20 Beta 10) ... but no :cry:
It does have the same behavior when threadsafe is not active,
the screen will not be restored.

Code: Select all

InitSprite()
InitKeyboard()

ExamineDesktops() 
OpenScreen(DesktopWidth(0), DesktopHeight(0), 32, "Screen")
 
 
Repeat

  Delay(100)
 FlipBuffers()
 If IsScreenActive()
   If ScreenActive = #False
     ScrenActive = #True
     CreateSprite(1,64,64)
   EndIf
   ClearScreen(0)
   Debug "Screen active"
   StartDrawing(SpriteOutput(1))
     Box(0, 0, 64, 64, 0)
     DrawingMode(1)
     DrawText(0,0,"Test", $FFFFFF)
    StopDrawing()
    DisplayTransparentSprite(1,64,64)
 Else
  ScreenActive = #False
 EndIf
 
 ExamineKeyboard()
 If KeyboardPushed(#PB_Key_Escape) : End : EndIf

ForEver
Post Reply