Start getting Blender default Font in Text rendering after long use #113044

Closed
opened 2023-09-29 09:31:36 +02:00 by alok · 11 comments

System Information:
Operating system: "Debian GNU/Linux"
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
CPU(s): 2
We are using Kubernetes to deploy our blend Application.

Blender Version:
Used bpy 3.5 package published in PyPI
link: https://pypi.org/project/bpy/3.5.0/

Description of error:
If there is a single pod available for a long time then after a certain no of file rendering [50k approx]. We start getting font problems. Every time we have received the same Blender default font in output .
We face problems with random blend files. Even if two blend files have the same font used one may work and the other may not.
After this affected file always gives rendered output with default font.

When issues start occurring we get Too many fonts!!! in the log multiple times.
This log has no fixed count.

After the pod restarts the same file starts working fine.

The same issue was reported by me here

steps to reproduce the error

  1. Keep blend file with fonts and images in a folder. read blend file as.
    bpy.ops.wm.open_mainfile(filepath='')

  2. render file using bpy package after updating text into it.

bpy.data.scenes["Scene"].sequence_editor.sequences[layer_name].text = 'replaceable text'
  bpy.context.scene.render.filepath = 'filename.png'
  bpy.data.scenes["Scene"].render.image_settings.file_format = 'PNG'
  bpy.ops.render.render(animation=False, write_still=True)

Please help me to fix this. This we have been facing for a long. After the Blender version upgrade [which was suggested in the last ticket] from 3.0 to 3.5 it still persists. But frequency has reduced.

**System Information:** Operating system: "Debian GNU/Linux" Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit CPU(s): 2 We are using Kubernetes to deploy our blend Application. **Blender Version:** Used bpy 3.5 package published in PyPI link: https://pypi.org/project/bpy/3.5.0/ **Description of error:** If there is a single pod available for a long time then after a certain no of file rendering [50k approx]. We start getting font problems. Every time we have received the same Blender default font in output . We face problems with random blend files. Even if two blend files have the same font used one may work and the other may not. After this affected file always gives rendered output with default font. When issues start occurring we get `Too many fonts!!!` in the log multiple times. This log has no fixed count. **After the pod restarts the same file starts working fine.** [The same issue was reported by me here](https://projects.blender.org/blender/blender/issues/80417#issuecomment-290809) **steps to reproduce the error** 1. Keep blend file with fonts and images in a folder. read blend file as. ` bpy.ops.wm.open_mainfile(filepath='')` 2. render file using bpy package after updating text into it. ``` bpy.data.scenes["Scene"].sequence_editor.sequences[layer_name].text = 'replaceable text' bpy.context.scene.render.filepath = 'filename.png' bpy.data.scenes["Scene"].render.image_settings.file_format = 'PNG' bpy.ops.render.render(animation=False, write_still=True) ``` Please help me to fix this. This we have been facing for a long. After the Blender version upgrade [which was suggested in the last ticket] from 3.0 to 3.5 it still persists. But frequency has reduced.
alok added the
Severity
Normal
Type
Report
Status
Needs Triage
labels 2023-09-29 09:31:36 +02:00
Member

Since d39abb74a0, we should have a maximum number of 64 fonts.

#define BLF_MAX_FONT 64

If I understand correctly, you never have more than ~64 fonts in one .blend file?
These just dont get "freed" when loading another .blend file, right?

@Harley might be interested
CC @ISS

Since d39abb74a0a99fde2c9d845821d52c198ae4da24, we should have a maximum number of 64 fonts. `#define BLF_MAX_FONT 64` If I understand correctly, you never have more than ~64 fonts in one .blend file? These just dont get "freed" when loading another .blend file, right? @Harley might be interested CC @ISS
Author

hey @lichtwerk ,
Thanks for your Quick reply.

  1. yes, correct. On average, we use 2 fonts at a time or max 4/5 fonts in one .blend file.
  2. yes seems so as I couldn't find any details to check but in this case, used blend files always renders file with the default font and logs the message as Too many fonts!!!
hey @lichtwerk , Thanks for your Quick reply. 1. yes, correct. On average, we use 2 fonts at a time or max 4/5 fonts in one .blend file. 2. yes seems so as I couldn't find any details to check but in this case, used blend files always renders file with the default font and logs the message as `Too many fonts!!!`

@alokkrchoudhary does this happen only when you render using BPY package? To reproduce we will need the .blend file and best would be to share fonts too if their license permits that.

@alokkrchoudhary does this happen only when you render using BPY package? To reproduce we will need the .blend file and best would be to share fonts too if their license permits that.
Richard Antalik added
Status
Needs Information from User
and removed
Status
Needs Triage
labels 2023-09-30 05:03:01 +02:00
Harley Acheson added
Status
Confirmed
and removed
Status
Needs Information from User
labels 2023-09-30 20:27:16 +02:00
Member

This is definitely an error of ours.

We maintain the list of current fonts in an array called global_font with a size of 64. We assign a font id to this when opening a font, and remove them with calls to BLF_unload, BLF_unload_id, and BLF_unload_all.

We clear the list in BLF_init(), called only from WM_init. This is in our main function, only called when the program starts up. We also clear the list in BLF_exit(), but this similarly only called in WM_exit in our main function when closing down.

Therefore, as illustrated in this complaint, if you start Blender, load a blend file that uses 40 unique fonts, then load a blend file containing 40 different fonts, you could get that "Too many fonts!!!."

We could find suitable places to call both BLF_exit() and BLF_init() when loading new files. These functions also initialize and deinitialize FreeType and we may not want that. and we don't want to strand any open FontBLFs.

BLF_unload_all() does safely clear global_font and properly frees the fonts. But this also frees the interface font. uiStyleInit() calls this and also loads the interface fonts, but this also assumes it is run just once and might keep adding to U.uistyles.

UI_style_init_default() clears U.uistyles and creates them again, including calling BLF_unload_all. But odd to deal with UI fonts when fixing a problem with the other fonts. And we might not be loading the file with UI, in which case we don't want to start using a potentially different UI font.

Needs some careful thought.

This is definitely an error of ours. We maintain the list of current fonts in an array called `global_font` with a size of 64. We assign a font id to this when opening a font, and remove them with calls to BLF_unload, BLF_unload_id, and BLF_unload_all. We clear the list in `BLF_init()`, called only from WM_init. This is in our main function, only called when the program starts up. We also clear the list in `BLF_exit()`, but this similarly only called in WM_exit in our main function when closing down. Therefore, as illustrated in this complaint, if you start Blender, load a blend file that uses 40 unique fonts, then load a blend file containing 40 different fonts, you could get that "Too many fonts!!!." We could find suitable places to call both BLF_exit() and BLF_init() when loading new files. These functions also initialize and deinitialize FreeType and we may not want that. and we don't want to strand any open FontBLFs. BLF_unload_all() does safely clear global_font and properly frees the fonts. But this also frees the interface font. uiStyleInit() calls this and also loads the interface fonts, but this also assumes it is run just once and might keep adding to U.uistyles. UI_style_init_default() clears U.uistyles and creates them again, including calling BLF_unload_all. But odd to deal with UI fonts when fixing a problem with the other fonts. And we might not be loading the file with UI, in which case we don't want to start using a potentially different UI font. Needs some careful thought.
Harley Acheson self-assigned this 2023-09-30 21:04:33 +02:00
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-10-03 01:21:14 +02:00
Author

hey @Harley,
Thanks a lot for the fix.

I want help/clarity with two things here:

  1. As explained by you in the above comment:
    Therefore, as illustrated in this complaint, if you start Blender, load a blend file that uses 40 unique fonts, then load a blend file containing 40 different fonts, you could get that "Too many fonts!!!."
    In this way, you are using a total of 80 different fonts to reproduce the issue but we have a specific limited set of fonts not more than 20. Once these are used for a long time then we start getting issues. Even the same font with one file works but with another file it doesn't. So will this fix be helpful here.

  2. As shared in issue description:

Used bpy 3.5 package published in PyPI
link: https://pypi.org/project/bpy/3.5.0/

I can see your fix PR is merged with blender-v4.0-release branch but I am using bpy==3.5.0 from PyPI. Can I expect the latest package available soon with the fix?

Thanks and regard
Alok

hey @Harley, Thanks a lot for the fix. I want help/clarity with two things here: 1. As explained by you in the above comment: `Therefore, as illustrated in this complaint, if you start Blender, load a blend file that uses 40 unique fonts, then load a blend file containing 40 different fonts, you could get that "Too many fonts!!!."` In this way, you are using a total of 80 different fonts to reproduce the issue but we have a specific limited set of fonts not more than 20. Once these are used for a long time then we start getting issues. Even the same font with one file works but with another file it doesn't. So will this fix be helpful here. 2. As shared in issue description: Used bpy 3.5 package published in PyPI link: https://pypi.org/project/bpy/3.5.0/ I can see your fix PR is merged with `blender-v4.0-release` branch but I am using bpy==3.5.0 from PyPI. Can I expect the latest package available soon with the fix? Thanks and regard Alok
alok reopened this issue 2023-10-03 12:51:04 +02:00
Blender Bot added
Status
Needs Triage
and removed
Status
Resolved
labels 2023-10-03 12:51:06 +02:00
Member

@alokkrchoudhary - So will this fix be helpful here.

This change was needed in that our font list was not cleared when loading new blend files. To know whether it truly solves all your issues (because you could have more than one), it would be best for you to test it yourself. Nightly builds on the buildbots for 4.0 Beta and 4.1 Alpha contain this change.

I can see your fix PR is merged with blender-v4.0-release branch but I am using bpy==3.5.0 from PyPI.

Besides going into 4.0 and 4.1 and newer, this fix will likely go into a future point release of 3.6 since that is a long-term support release. Probably for 3.6.5.

@alokkrchoudhary - So will this fix be helpful here. This change was needed in that our font list was not cleared when loading new blend files. To know whether it truly solves all your issues (because you could have more than one), it would be best for you to test it yourself. Nightly builds on the buildbots for 4.0 Beta and 4.1 Alpha contain this change. > I can see your fix PR is merged with `blender-v4.0-release` branch but I am using bpy==3.5.0 from PyPI. Besides going into 4.0 and 4.1 and newer, this fix will likely go into a future point release of 3.6 since that is a long-term support release. Probably for 3.6.5.
Author

okay @Harley ,
I will wait for bpy 3.6.5 PyPi package which will include the fix. Once that is published I will test my setup and if the issue is found I will report again.

Thanks.

okay @Harley , I will wait for `bpy 3.6.5 PyPi package` which will include the fix. Once that is published I will test my setup and if the issue is found I will report again. Thanks.
Member

OK, I have added the fix to the LTS backport list #109399 now.

Will close this report then, 3.6.5 should be out Oct 17, 2023, the pypi package should probably be out soon after

OK, I have added the fix to the LTS backport list #109399 now. Will close this report then, 3.6.5 should be out Oct 17, 2023, the pypi package should probably be out soon after
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-10-04 09:45:24 +02:00
Author

hey @lichtwerk ,

We would like to know about the status of the pypi package [bpy= 3.6.5] with the mentioned fix. Is there a planned release for this package or are there any known delays? We are experiencing issues randomly with the current package.

Thanks.
Alok

hey @lichtwerk , We would like to know about the status of the pypi package [bpy= 3.6.5] with the mentioned fix. Is there a planned release for this package or are there any known delays? We are experiencing issues randomly with the current package. Thanks. Alok
Member

hey @lichtwerk ,

We would like to know about the status of the pypi package [bpy= 3.6.5] with the mentioned fix. Is there a planned release for this package or are there any known delays? We are experiencing issues randomly with the current package.

Thanks.
Alok

I have to apologize, seems bpy is only build for full releases (so 4.0 would be next, this is scheduled for Nov 14, 2023).
I'll try to find out if we can built this more often (also for point releases).

> hey @lichtwerk , > > We would like to know about the status of the pypi package [bpy= 3.6.5] with the mentioned fix. Is there a planned release for this package or are there any known delays? We are experiencing issues randomly with the current package. > > Thanks. > Alok I have to apologize, seems `bpy` is only build for full releases (so 4.0 would be next, this is scheduled for Nov 14, 2023). I'll try to find out if we can built this more often (also for point releases).
Author

Okay, Thanks for the details :)

Okay, Thanks for the details :)
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
4 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#113044
No description provided.