Script autorun closes immediately on Windows #45699

Closed
opened 2015-08-05 23:57:02 +02:00 by Jeremy Nicola · 19 comments

System Information
Windows 7, Intel HD Graphics 4000
Bug has been confirmed to appear with other (unkown) graphics cards

Blender Version
Broken: from 2.68
Worked: until 2.67b

Short description of error
On Windows, from Blender 2.68, when running a python script from the command line the blender game engine closes as soon as it starts: the Blender game engine starts, the scene is shown, and it closes and the terminal says "Blender Game engine Stopped".
In the same conditions, the Blender Game Engine runs fine on OSX and Linux.

Exact steps for others to reproduce the error
In a console, in the same folder as the Blender executable, autorun.blend and test.py:
blender -d autorun.blend -y -P test.py

  • On Linux the Game Engine runs and the cube is shown (any version from 2.67a to 2.75a).
  • On OSX Yosemite the Game Engine runs and the cube is shown (tested with 2.75a)
  • On Windows with version 2.67a the Game Engine runs and the cube is shown
  • On Windows with version 2.68 and above the Game Engine closes as soon as it opened and the program terminates.

I think the bug was introduced in commit 412c043474, but I can't confirm.

We are using this option to run robotics simulation using the Game Engine with MORSE (https://www.openrobots.org/morse/doc/latest/morse.html).
A work around on Windows is to uncheck the "Auto start" property of the autorun.blend file in the Game menu, launch the same command as above and then press "p" to launch the simulation (which works).

We would really appreciate if this bug can be fixed, let me know how I can help.

Jeremy Nicola

**System Information** Windows 7, Intel HD Graphics 4000 Bug has been confirmed to appear with other (unkown) graphics cards **Blender Version** Broken: from 2.68 Worked: until 2.67b **Short description of error** On Windows, from Blender 2.68, when running a python script from the command line the blender game engine closes as soon as it starts: the Blender game engine starts, the scene is shown, and it closes and the terminal says "Blender Game engine Stopped". In the same conditions, the Blender Game Engine runs fine on OSX and Linux. **Exact steps for others to reproduce the error** In a console, in the same folder as the Blender executable, [autorun.blend](https://archive.blender.org/developer/F220453/autorun.blend) and [test.py](https://archive.blender.org/developer/F220455/test.py): blender -d autorun.blend -y -P test.py - On Linux the Game Engine runs and the cube is shown (any version from 2.67a to 2.75a). - On OSX Yosemite the Game Engine runs and the cube is shown (tested with 2.75a) - On Windows with version 2.67a the Game Engine runs and the cube is shown - On Windows with version 2.68 and above the Game Engine closes as soon as it opened and the program terminates. I think the bug was introduced in commit 412c043474, but I can't confirm. We are using this option to run robotics simulation using the Game Engine with MORSE (https://www.openrobots.org/morse/doc/latest/morse.html). **A work around on Windows** is to uncheck the "Auto start" property of the [autorun.blend](https://archive.blender.org/developer/F220453/autorun.blend) file in the Game menu, launch the same command as above and then press "p" to launch the simulation (**which works**). We would really appreciate if this bug can be fixed, let me know how I can help. Jeremy Nicola
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @JeremyNicola

Added subscriber: @JeremyNicola

Added subscriber: @sindra1961

Added subscriber: @sindra1961

The Game Engine runs in my environment (win32), and the cube is shown.
{F220478}autorun.log
version 2.75 (sub 4), branch b'master', commit date b'2015-08-04' b'19:56', hash b'd39e188', b'Release'

The Game Engine runs in my environment (win32), and the cube is shown. {[F220478](https://archive.blender.org/developer/F220478/autorun.png)}[autorun.log](https://archive.blender.org/developer/F220480/autorun.log) version 2.75 (sub 4), branch b'master', commit date b'2015-08-04' b'19:56', hash b'd39e188', b'Release'
Author

Well, too bad for the reproductibility :-/...

here is my log with 2.75 on Windows:
debug2.75_windows.txt
you can see that the script "test.py" was not executed as "Hello Blender" does not appear, contrarily to your log.

Well, too bad for the reproductibility :-/... here is my log with 2.75 on Windows: [debug2.75_windows.txt](https://archive.blender.org/developer/F220483/debug2.75_windows.txt) you can see that the script "test.py" was not executed as "Hello Blender" does not appear, contrarily to your log.
Member

Added subscriber: @hg1

Added subscriber: @hg1
Member

The way you are running the script is for Blender scripts not for BGE. So basically it would be a Blender and not a BGE bug if there is really a bug.
Because on my Windows 7 PC with Blender 32 bit version 2.75a it will work and will print "Hello Blender".
Console Output.txt

Please read the documentation about Scripting & Security. Maybe you have to activate Auto Run Python Scripts once to add the parameter to the settings. After that you can disable it and use -y or --enable-autoexec if you want.
http://wiki.blender.org/index.php/Doc%3A2.6/Manual/Extensions/Python/Security
http://wiki.blender.org/index.php/Doc:2.4/Manual/Render/Command_Line

But basically this is not the right way to run a BGE script. The way you are using is to run a Blender script (bpy). And will only run once at startup and will be not called while the the BGE is running. The normal way to run a BGE script is to use a Python module controller and a always sensor.

If you want to start the BGE game from the console you have have to use the Blenderplayer.
"blender -d autorun.blend -y -P test.py" -y and -P are not existing for the Blenderplayer and you can't load a python script like blender Blender script.
So you have to use "blenderplayer -d autorun.blend"

The way you are running the script is for Blender scripts not for BGE. So basically it would be a Blender and not a BGE bug if there is really a bug. Because on my Windows 7 PC with Blender 32 bit version 2.75a it will work and will print "Hello Blender". [Console Output.txt](https://archive.blender.org/developer/F221685/Console_Output.txt) Please read the documentation about Scripting & Security. Maybe you have to activate Auto Run Python Scripts once to add the parameter to the settings. After that you can disable it and use -y or --enable-autoexec if you want. http://wiki.blender.org/index.php/Doc%3A2.6/Manual/Extensions/Python/Security http://wiki.blender.org/index.php/Doc:2.4/Manual/Render/Command_Line But basically this is not the right way to run a BGE script. The way you are using is to run a Blender script (bpy). And will only run once at startup and will be not called while the the BGE is running. The normal way to run a BGE script is to use a Python module controller and a always sensor. If you want to start the BGE game from the console you have have to use the Blenderplayer. "blender -d autorun.blend -y -P test.py" -y and -P are not existing for the Blenderplayer and you can't load a python script like blender Blender script. So you have to use "blenderplayer -d autorun.blend"
Member

Added subscribers: @JorgeBernalMartinez, @ideasman42

Added subscribers: @JorgeBernalMartinez, @ideasman42

Added subscriber: @Sergey

Added subscriber: @Sergey

@ideasman42, seems we just need to disable safety features for game engine?

@ideasman42, seems we just need to disable safety features for game engine?
Author

I am able to build from 2.67b (doesn't show the bad behavior) to current release (shows the bad behavior) on Windows.
I am pretty busy at the moment, by the end of the month I will git bisect and report what I found.

I am able to build from 2.67b (doesn't show the bad behavior) to current release (shows the bad behavior) on Windows. I am pretty busy at the moment, by the end of the month I will git bisect and report what I found.
Campbell Barton self-assigned this 2015-09-13 16:45:56 +02:00

This issue was referenced by 5611237391

This issue was referenced by 5611237391db8badf5e64dc559b5ac456631e1de

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'

Accidentally pasted in wrong tracker number!

Accidentally pasted in wrong tracker number!

Confirmed the bug, looking into a fix.

Update, its caused by: 24321d4891

Whats happening is the BGE is checking the window is still set in BL_KetsjiNextFrame, see /* window closed while bge runs */.

From commit 24321d4891, the added call to wm_event_do_handlers which sets the window context to NULL.

Confirmed the bug, looking into a fix. Update, its caused by: 24321d4891 Whats happening is the BGE is checking the window is still set in `BL_KetsjiNextFrame`, see `/* window closed while bge runs */`. From commit 24321d4891, the added call to `wm_event_do_handlers` which sets the window context to `NULL`.

This issue was referenced by 3056add0e0

This issue was referenced by 3056add0e0b087f7e08781095fcdd99d08ca8f25

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author

Great, thank you!

Great, thank you!
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
7 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#45699
No description provided.