Example `demo.nim` error
matkuki opened this issue · comments
Hi,
Specs: Windows 10 x64, Nim 1.6.8
Error:
A lot of the times when running the demo
example (but not always), I get this:
...
[load] data\shadow-button-middle.png
putFlippy: (45, 122) @ data\shadow-button-middle.png
UI event!
new checkbox
Traceback (most recent call last)
J:\Nim\fidgetty\examples\demo.nim(162) demo
J:\Nim\fidgetty\src\fidgetty\fidget_dev\openglbackend.nim(199) startFidget
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncdispatch.nim(1961) waitFor
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncdispatch.nim(1653) poll
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncdispatch.nim(419) runOnce
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncdispatch.nim(234) processPendingCallbacks
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncmacro.nim(28) runningNimAsyncContinue
J:\Nim\fidgetty\src\fidgetty\fidget_dev\openglbackend.nim(193) runningIter
J:\Nim\fidgetty\src\fidgetty\fidget_dev\opengl\base.nim(172) updateLoop
J:\Nim\fidgetty\src\fidgetty\fidget_dev\opengl\base.nim(139) drawAndSwap
J:\Nim\fidgetty\src\fidgetty\fidget_dev\openglbackend.nim(91) :anonymous
J:\Nim\fidgetty\src\fidgetty\widgets.nim(111) testDemo
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\system\arc.nim(172) nimDestroyAndDispose
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\system\arc.nim(198) nimDecRefIsLast
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
That's odd. Just to check have you updated to the latest Fidgetty? It sort of looks like a potential compiler bug, maybe Windows specific. That section of code should always have those ref objects allocated.
Maybe you could add some assert
statements in widgets.nim:111
for assert item.isNil == false
and assert state.isNil == false
and re-run it? I'll add some there but I don't have a windows install to check it currently and I haven't gotten it on Mac/Linux.
That's odd. Just to check have you updated to the latest Fidgetty?
Yes, I'm at commit HEAD is now at aec2b9c adding cells example
Maybe you could add some assert statements in widgets.nim:111 for assert item.isNil == false and assert state.isNil == false and re-run it?
Added that same error, only the line has changed:
...
UI event!
new checkbox
Traceback (most recent call last)
J:\Nim\fidgetty\examples\demo.nim(162) demo
J:\Nim\fidgetty\src\fidgetty\fidget_dev\openglbackend.nim(199) startFidget
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncdispatch.nim(1961) waitFor
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncdispatch.nim(1653) poll
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncdispatch.nim(419) runOnce
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncdispatch.nim(234) processPendingCallbacks
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncmacro.nim(28) runningNimAsyncContinue
J:\Nim\fidgetty\src\fidgetty\fidget_dev\openglbackend.nim(193) runningIter
J:\Nim\fidgetty\src\fidgetty\fidget_dev\opengl\base.nim(172) updateLoop
J:\Nim\fidgetty\src\fidgetty\fidget_dev\opengl\base.nim(139) drawAndSwap
J:\Nim\fidgetty\src\fidgetty\fidget_dev\openglbackend.nim(91) :anonymous
J:\Nim\fidgetty\src\fidgetty\widgets.nim(113) testDemo
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\system\arc.nim(172) nimDestroyAndDispose
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\system\arc.nim(198) nimDecRefIsLast
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Funny observation: this only happens if I run the demo from the Windows console
, if I run it with double-clicking the executable in the explorer
, it never throws this error!
Funny observation: this only happens if I run the demo from the Windows console, if I run it with double-clicking the executable in the explorer, it never throws this error!
That is very odd. I'm going to post this on the Nim forum and see if people have thoughts about it.
Compiling with --mm:orc
gives a different error:
...
UI event!
new checkbox
Traceback (most recent call last)
J:\Nim\fidgetty\examples\demo.nim(162) demo
J:\Nim\fidgetty\src\fidgetty\fidget_dev\openglbackend.nim(199) startFidget
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncdispatch.nim(1961) waitFor
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncdispatch.nim(1653) poll
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncdispatch.nim(419) runOnce
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncdispatch.nim(234) processPendingCallbacks
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\pure\asyncmacro.nim(28) runningNimAsyncContinue
J:\Nim\fidgetty\src\fidgetty\fidget_dev\openglbackend.nim(193) runningIter
J:\Nim\fidgetty\src\fidgetty\fidget_dev\opengl\base.nim(172) updateLoop
J:\Nim\fidgetty\src\fidgetty\fidget_dev\opengl\base.nim(139) drawAndSwap
J:\Nim\fidgetty\src\fidgetty\fidget_dev\openglbackend.nim(95) :anonymous
J:\Nim\fidgetty\src\fidgetty\fidget_dev\common.nim(762) computeLayout
J:\Nim\fidgetty\src\fidgetty\fidget_dev\common.nim(762) computeLayout
J:\Nim\fidgetty\src\fidgetty\fidget_dev\common.nim(762) computeLayout
J:\Nim\fidgetty\src\fidgetty\fidget_dev\common.nim(810) computeLayout
J:\Nim\fidgetty\src\fidgetty\fidget_dev\openglbackend.nim(29) :anonymous
C:\Users\matic\.nimble\pkgs\typography-#head\typography\layout.nim(168) typeset
C:\Users\matic\.nimble\pkgs\typography-#head\typography\rasterizer.nim(47) getGlyphSize
C:\Users\matic\.nimble\pkgs\typography-#head\typography\rasterizer.nim(18) makeReady
C:\Users\matic\.nimble\pkgs\typography-#head\typography\opentype\parser.nim(647) parseGlyph
C:\Users\matic\.nimble\pkgs\typography-#head\typography\opentype\parser.nim(608) parseCompositeGlyphC:\Users\matic\.nimble\pkgs\typography-#head\typography\opentype\parser.nim(649) parseGlyph
C:\Users\matic\.nimble\pkgs\typography-#head\typography\opentype\parser.nim(491) parseGlyphPath
C:\Users\matic\.nimble\pkgs\pixie-5.0.1\pixie\paths.nim(348) moveTo
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\system\alloc.nim(956) alloc
C:\Users\matic\.choosenim\toolchains\nim-1.6.8\lib\system\alloc.nim(788) rawAlloc
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Nice, the difference with the ORC could be helpful. Though thats in the pixie layer, which would be annoying to trackdown.
Could you try just commenting the doBlocks
(line 115) out and see if the error occurs? Thats just the event handlers templates, so it may produce odd code.
Are you seeing this error on any of the simpler test guis, like testDropdown.nim?
Oh, also I could add a try block around the code
line. That might make a better trace.
Could you try just commenting the doBlocks (line 115) out and see if the error occurs?
No change.
Oh, also I could add a try block around the code line.
No change, same traceback. Tried putting just the code
line in a try/except, tried also from putting lines from 110 to 117 in a try/except. Nothing changes, except the error line shifts one line down because of the inserted try:
.
Why does the compiler throw an error when trying to compile with other --mm
options, like refc
and markAndSweep
for example?
Why does the compiler throw an error when trying to compile with other --mm options, like refc and markAndSweep for example?
Likely some parts of the code depends on destructor's or other behaviors of ARC/ORC. I'll give it a quick compile and see if there's it'd be feasible to use refc.
Looks like it was just an issue with setting the mm
options in the config. I think it's a compiler glitch as the user setting --mm
should override the configs. 🤷
I added a -d:fidgettyNonArcGc
flag that will let you compile with refc
or others. But the tests and examples default to --mm:arc
so it'll still default to that.
Could you try just commenting the doBlocks (line 115) out and see if the error occurs?
No change.
Oh, also I could add a try block around the code line.
No change, same traceback. Tried putting just the
code
line in a try/except, tried also from putting lines from 110 to 117 in a try/except. Nothing changes, except the error line shifts one line down because of the insertedtry:
.
Okay, and that's pretty annoying. :/
It really does seem like some odd compiler issue. Let me know if that refc works. Also, could you run the tbutton.nim
test and see if it occurs with it too? I think that'd be a minimal example we could post to the Nim forum.
P.S. the new theming is coming along nicely! You can do pseudo css like styling without needing to modify widgets at all.
fidgetty/src/fidgetty/themes.nim
Line 79 in bad155e
When trying to compile with nim c --mm:refc -d:fidgettyNonArcGc demo.nim
, I get:
...\fidgetty\src\fidgetty\theming.nim(2, 15) Error: cannot open file: cssgrid/atoms
I tried removing cssgrid
and installing the whole fidgetty
again with nimble install
in the root directory, but still the above error persists.
Ok, I fixed those errors and updated the nimble.
Updated, now I get this error, with whatever switches I compile with:
J:\Nim\fidgetty\src\fidgetty\button.nim(12, 16) Error: type mismatch: got <Palette>
but expected one of:
proc cornerRadius(): UICoord
first type mismatch at position: 1
extra argument given
proc cornerRadius(a, b, c, d: UICoord | float | float32)
first type mismatch at position: 1
required type for a: UICoord or float or float32
but expression 'currentPalette' is of type: Palette
proc cornerRadius(radius: (UICoord, UICoord, UICoord, UICoord))
first type mismatch at position: 1
required type for radius: (UICoord, UICoord, UICoord, UICoord)
but expression 'currentPalette' is of type: Palette
proc cornerRadius(radius: UICoord | float | float32)
first type mismatch at position: 1
required type for radius: UICoord or float or float32
but expression 'currentPalette' is of type: Palette
expression: cornerRadius currentPalette
What branch are you using again? That's odd, it's a normal compile issue. But pretty sure I ran the nimble tests on all the branches. I'll run them and check again.
Ah, it's the devel
branch. Ok the new themes are mostly working, so I'll just merge those changes in.
Definitely let me know if you find missing parts of the theme! I'm still switching the widgets over to the new theme setup.
Ugh, that was annoying. I merged in the new themes system and fixed all the compilation issues. I think all the widgets should be themed enough to be useable.
edit: ugh, it merged into main
, not devel
. Welp, I guess new theme system is out for everyone!
Tried the devel
and main
branches, both throw:
fidgetty\src\fidgetty\fidget_dev.nim(7, 18) Error: cannot open file: fidget_dev/theming
You may need to add nim c -f
one time? Sometimes the Nim compiler cache gets outta sync and I had the same thing happen to a few of my test files.
I also pushed a change to fidget_devel
on the devel branch to see if that helps. :)
I did a git switch devel
, git reset --hard
, git pull origin
, then tried:
nim c demo.nim
nim c -f demo.nim
nim c --mm:refc -d:fidgettyNonArcGc demo.nim
... all still give the same error:
J:\Nim\fidgetty\examples> nim c --mm:refc -d:fidgettyNonArcGc .\demo.nim
Hint: used config file 'C:\Users\matic\.choosenim\toolchains\nim-1.6.8\config\nim.cfg' [Conf]
Hint: used config file 'C:\Users\matic\.choosenim\toolchains\nim-1.6.8\config\config.nims' [Conf]
Hint: used config file 'J:\Nim\fidgetty\config.nims' [Conf]
Hint: used config file 'J:\Nim\fidgetty\examples\config.nims' [Conf]
................................................................................................................................................................
..................................................
J:\Nim\fidgetty\src\fidgetty\fidget_dev\patches\textboxes.nim(511, 8) Hint: duplicate import of 'strformat'; previous import here: J:\Nim\fidgetty\src\fidgetty\
fidget_dev\patches\textboxes.nim(145, 8) [DuplicateModuleImport]
J:\Nim\fidgetty\src\fidgetty\fidget_dev\patches\textboxes.nim(145, 8) Warning: imported and not used: 'strformat' [UnusedImport]
J:\Nim\fidgetty\src\fidgetty\fidget_dev\patches\textboxes.nim(511, 8) Warning: imported and not used: 'strformat' [UnusedImport]
.
J:\Nim\fidgetty\src\fidgetty\fidget_dev\common.nim(19, 8) Warning: imported and not used: 'print' [UnusedImport]
J:\Nim\fidgetty\src\fidgetty\fidget_dev\common.nim(931, 11) Warning: imported and not used: 'monotimes' [UnusedImport]
J:\Nim\fidgetty\src\fidgetty\fidget_dev\common.nim(931, 26) Warning: imported and not used: 'times' [UnusedImport]
J:\Nim\fidgetty\src\fidgetty\fidget_dev.nim(8, 18) Error: cannot open file: fidget_dev/theming
I'm thinking you might still have my old Fidget fork installed in Nimble? It could be mixing up paths. You should be able to uninstall that using something like nimble uninstall fidget
.
Either that or it's an oddity with Windows path. You could try running it from the main directory like nim c -r examples/demo.nim
.
Thanks for checking. Looking under src/fidgetty/fidget_dev/ I’m not seeing theming.nim. Bet it’s a git ignore issue. Let me check that.
Huzzah! Finally found a gitignore pattern that ignores binaries but not Nim source files. Honestly the pattern makes no sense to me at first glance, but works: https://stackoverflow.com/questions/5711120/gitignore-binary-files-that-have-no-extension/53416684#53416684
I added theming.nim
and pushed it onto main and devel.
P.S. if you want to run examples from the examples folder you may need to add the DataDir
path like: cd examples/ && nim c -r -d:DataDirPath:../data/ demo.nim
This addition that you mentioned -d:DataDirPath:../data/
fixes the original console-execute errors!!! With all --mm
flags!
To make the demo work, I copied the fidgetty/data
directory into fidgetty/examples
, so it looks like this:
Shouldn't that work exactly the same as the your new -d:DataDirPath:../data/
flag?