Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LuxCore property number to string conversion is affected by locale #390

Closed
kintuX opened this issue Jun 4, 2020 · 17 comments
Closed

LuxCore property number to string conversion is affected by locale #390

kintuX opened this issue Jun 4, 2020 · 17 comments
Assignees
Labels

Comments

@kintuX
Copy link

kintuX commented Jun 4, 2020

See issue LuxCoreRender/BlendLuxCore#477

.blend file: https://github.com/LuxCoreRender/BlendLuxCore/files/4728948/PointLightBanding-BUG.zip

Steps to reproduce:
Set Object or Material ID to -1.
Export/Write scene using LuxCore Filesaver as Text.
Load the scene file w/ LuxCoreUI

Error message from LuxCoreUI console: RenderConfig loading error: bad lexical cast: source type value could not be interpreted as target

OS: W10
Blender version: 2.83
LuxCore version: 2.4 beta2 (e15e45c)
BlendLuxCore version: 2.4beta2 (8e6ca69)

@Theverat
Copy link
Member

Theverat commented Jun 5, 2020

As Dade said here: LuxCoreRender/BlendLuxCore#477 (comment)

You C library printing integer numbers with ",".

@Theverat Theverat changed the title Negative Object/Material IDs make LuxCore Filesaver write wrong output LuxCore property number to string conversion is affected by locale Jun 5, 2020
@Theverat Theverat transferred this issue from LuxCoreRender/BlendLuxCore Jun 5, 2020
@Theverat
Copy link
Member

Theverat commented Jun 5, 2020

@Dade916 Can we maybe use a custom number to string function that is not affected by the locale or C library?

@Dade916
Copy link
Member

Dade916 commented Jun 5, 2020

But it is a bit strange, first of all, ID are unsigned int so -1 isn't a valid number, wasn't it used in BlendLuxCore to mark the default (random) assigned values ? I assume -1 should be exported as 2^32 = 4294967296.

Anyway @kintuX, are you sure the problem doesn't happen if if you use a value like 1000 ? I have the feeling it will be printed as "1,000".

@kintuX
Copy link
Author

kintuX commented Jun 5, 2020

But it is a bit strange, first of all, ID are unsigned int so -1 isn't a valid number, wasn't it used in BlendLuxCore to mark the default (random) assigned values ? I assume -1 should be exported as 2^32 = 4294967296.

Anyway @kintuX, are you sure the problem doesn't happen if if you use a value like 1000 ? I have the feeling it will be printed as "1,000".

Yes, it does that. Prints with commas ---> 1000 = 1,000
Replacing commas with periods ---> 1.000 causes same issue & error report.
Finally, it works fine without any symbols ---> 1000

@Dade916
Copy link
Member

Dade916 commented Jun 5, 2020

@Dade916 Can we maybe use a custom number to string function that is not affected by the locale or C library?

But it should work anyway, I mean: I write and read the number with the same library, it should be able to read what it writes.

This may be some kind of side effect of some Blender setting. LuxCore standalone expect the number in "C" locale format (without "," or ".", as it should be) while LuxCore inside Blender starts to print numbers with ",". Blender must use a different locale. I will try to figure out a solution.

But it is problematic, all the "locale" idea is considered totally broken and useless. It is a global application setting and, as you see, it does a mess most of the times.

@kintuX
Copy link
Author

kintuX commented Jun 5, 2020

OK, I found a setting which causes this string conversion in Blender.

Preference Editor > Interface > Translation > Language > ...
BlenderPrefTransAuto-OK

I had Language set to English. Now, with Automatic it doesn't do any conversion but keeps "original" string.

@Theverat
Copy link
Member

Theverat commented Jun 5, 2020

I think we can show a warning in the addon before rendering if the language is set to something other than "Automatic".

But it should work anyway, I mean: I write and read the number with the same library, it should be able to read what it writes.
This may be some kind of side effect of some Blender setting. LuxCore standalone expect the number in "C" locale format (without "," or ".", as it should be) while LuxCore inside Blender starts to print numbers with ",". Blender must use a different locale. I will try to figure out a solution.

It really looks like this is a Blender problem, but it could be a problem when LuxCore is embedded in other applications, too. In my opinion it would be best to use a string conversion that doesn't depend on the locale.
These two might be interesting:

@Dade916
Copy link
Member

Dade916 commented Jun 9, 2020

I pushed a tentative fix to the problem. It is, for the moment, limited to properties but it should fix the problem described in this issue.

@kintuX, can you try if it works now with the "automatic" setting ?

@Dade916
Copy link
Member

Dade916 commented Jun 9, 2020

Related to #103

@Dade916 Dade916 marked this as a duplicate and then as not a duplicate of #103 Jun 9, 2020
@kintuX
Copy link
Author

kintuX commented Jun 10, 2020

With "Automatic" it was already working. The issue was with "English" or other Languages set.
Anyways, now BlendLuxcore & LuxCoreUI stop responding at: "EmbreeAccel build time"
No error, just freeze. Must force quit.

and Sorry for the late reply I was "off-grid"


Edit 1

Found out the scene I was testing on got corrupt. So I made a new one.

Result:
Blender 2.83 with Language set to English, BlendLuxCore writes out "1000" as "1,000" (as usual) and LuxCoreUI (1aa31a4) still can't load it:
[SDL][7.484] Material definition: Material1735320947848 RenderConfig loading error: bad lexical cast: source type value could not be interpreted as target

@Dade916
Copy link
Member

Dade916 commented Jun 11, 2020

I'm starting to have the feeling the problem may be in BlendLuxCore: @Theverat can you check if the material.id property is set as number and not as string ? I mean, if Blender gives the string "1,000" to BlendLuxCore and BlendLuxCore sets the property value as string, and not as a number, LuxCore will print the string "1,000".
In this case locale would be not affect how the string is handled inside LuxCore API.

@kintuX, are you just setting language to "English" to replicate the problem ? Do you have default language/nation related system settings ?

@kintuX
Copy link
Author

kintuX commented Jun 11, 2020

@Dade916 Yes, I only switch in Blender from Automatic to English. I have Windows sytem using default language English US but with International Standard (metric units, date, CET time, EU number punctuation, € currency...)

I also suspect it's BlendLuxCore issue. BTW, I think @Theverat is away for a week.

@Dade916
Copy link
Member

Dade916 commented Jun 11, 2020

I'm starting to think to a BlendLuxCore problem because it is quite strange to see this problem only with material.id while all other numbers seem to be printed fine.

@Theverat
Copy link
Member

@Theverat can you check if the material.id property is set as number and not as string ?

It is set as integer, as far as I can see.

@Dade916
Copy link
Member

Dade916 commented Jun 27, 2020

I'm trying to replicate the problem, my Blender "Preference Editor > Interface > Translation > Language" was already set to "English" and it works fine. I assume there is something in @kintuX OS setting causing the problem.
If I can not replicate the problem, I can not fix it.

@kintuX
Copy link
Author

kintuX commented Aug 4, 2020

Here are another strange cases, files showing same issues, but aren't any commas present (already replaced w/ periods)...
there's also ongoing chat on Discord
lux file saver commaFix.zip

@Dade916 Dade916 self-assigned this Sep 25, 2020
@Dade916 Dade916 added the bug label Sep 25, 2020
@Dade916 Dade916 added this to To do in LuxCoreRender v2.5 via automation Sep 25, 2020
@Dade916
Copy link
Member

Dade916 commented Sep 25, 2020

As far as I know, this problem as been fixed (the relative discussion was on our forum).
https://forums.luxcorerender.org/viewtopic.php?f=4&t=2526&hilit=bad+lexical+cast&start=20#p25304

@Dade916 Dade916 closed this as completed Sep 25, 2020
LuxCoreRender v2.5 automation moved this from To do to Done Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

No branches or pull requests

3 participants