GithubHelp home page GithubHelp logo

gtigen panic about core HOT 25 CLOSED

ddkwork avatar ddkwork commented on June 2, 2024
gtigen panic

from core.

Comments (25)

ddkwork avatar ddkwork commented on June 2, 2024

we need change InspectGenDecl func as:

			for i, field := range st.Fields.List {
				if field == nil {//---------------------------------------> add this 
					continue
				}
				// if we have no names, we are embed, so add to embeds and remove from fields
				if len(field.Names) == 0 {
					emblist.List = append(emblist.List, field)
					st.Fields.List = slices.Delete(st.Fields.List, i+delOff, i+1+delOff) // we need to add delOff to correctly handle situations where we delete multiple times and our indices become inaccurate
					delOff--                                                             // we have deleted so we need to update offset
				}
			}

from core.

kkoreilly avatar kkoreilly commented on June 2, 2024

I can not reproduce this issue; are you doing anything other than just running go test in gtigen?

from core.

kkoreilly avatar kkoreilly commented on June 2, 2024

The reason that the test is failing is that you are running it outside of the normal location of the code, which means that it can not load the correct files for the test, and thus it panics. I do not know why GoLand decides to put everything in bizarre temporary locations, as that is the cause of both this issue and the Vulkan panic. This will work if you run the test in the normal way by just running go test in gtigen, so this is not an issue. We will not support running tests in the wrong location, and the test works perfectly with both the standard command line workflow and VS Code. You can probably configure GoLand to place executables and tests in the current directory. Adding a pointless nil check does not fix this problem; you are conflating not panicking and working: just because something doesn't panic doesn't mean that it works. Most of the nil panic issues are caused by other problems, and adding a simple nil check almost never fixes the actual problem.

from core.

ddkwork avatar ddkwork commented on June 2, 2024

Ok

from core.

ddkwork avatar ddkwork commented on June 2, 2024
{19DC250D-FDB0-4859-B319-DE34EE770600}

from core.

ddkwork avatar ddkwork commented on June 2, 2024

I have a different take on this issue.

from core.

ddkwork avatar ddkwork commented on June 2, 2024
			for i := 0; i < len(st.Fields.List); i++ {
				field := st.Fields.List[i]
				// if we have no names, we are embed, so add to embeds and remove from fields
				if len(field.Names) == 0 {
					emblist.List = append(emblist.List, field)
					st.Fields.List = slices.Delete(st.Fields.List, i+delOff, i+1+delOff) // we need to add delOff to correctly handle situations where we delete multiple times and our indices become inaccurate
					i++
					delOff-- // we have deleted so we need to update offset
				}
			}

from core.

ddkwork avatar ddkwork commented on June 2, 2024

As for vulkan, as long as you've successfully mocked the various events inside the unit tests, I'll patiently debug it and see if I can find the cause of the actual panic. But between the invisibility of cgo code to debugging, I'm not sure, unless there's an alternative way to intercept the cgo execution flow

from core.

kkoreilly avatar kkoreilly commented on June 2, 2024

Please tell me whether the gtigen test still panics when you run it in Git Bash with go test.

from core.

ddkwork avatar ddkwork commented on June 2, 2024

from core.

kkoreilly avatar kkoreilly commented on June 2, 2024

Please send me a screenshot of you running go test in gtigen.

from core.

ddkwork avatar ddkwork commented on June 2, 2024
{5D2349C6-FE1C-4b8f-BC74-510FF7FEE0C6}

from core.

kkoreilly avatar kkoreilly commented on June 2, 2024

It is really weird that it panics on your computer but not mine. I will work on debugging this now.

from core.

ddkwork avatar ddkwork commented on June 2, 2024

You write the code you should be very clear about the logic of its implementation, slice 5 members, deleted a, the remaining 4, range to the fourth time, 4 is index, starting from 0, in fact, he is 5, but has been deleted, so the empty pointer panic

from core.

ddkwork avatar ddkwork commented on June 2, 2024
			for i := 0; i < len(st.Fields.List); i++ {
				field := st.Fields.List[i]
				// if we have no names, we are embed, so add to embeds and remove from fields
				if len(field.Names) == 0 {
					emblist.List = append(emblist.List, field)
					st.Fields.List = slices.Delete(st.Fields.List, i+delOff, i+1+delOff) // we need to add delOff to correctly handle situations where we delete multiple times and our indices become inaccurate
					i++
					delOff-- // we have deleted so we need to update offset
				}
			}

This fix perfectly matches the execution logic of your code

from core.

kkoreilly avatar kkoreilly commented on June 2, 2024

Sorry, I misunderstood the situation, and I will apply that fix now.

from core.

ddkwork avatar ddkwork commented on June 2, 2024

I would like to ask you a question, I'm trying to understand the execution of core by debugging, but I have not been able to find the place where the reflected structure is. For example:

func TestStructView(t *testing.T) {
	b := gi.NewBody()
	NewStructView(b).SetStruct(myStructValue)
	b.AssertRender(t, "structview/basic")
}

As I understand it, SetStruct is supposed to perform reflection, i.e.: reflect the struct to the ki n-forked tree structure, then various traversals to add events, styles, etc. to send to vulkan, and finally vulkan hands it off to glfw to interact with the graphics card hardware. But I didn't find any code related to the reflection structure.

from core.

kkoreilly avatar kkoreilly commented on June 2, 2024

You are asking how the entire architecture of Cogent Core is structured, which is a hard question to easily answer. I will write architecture documentation that explains all of that soon, but until then, here is a simple answer: SetStruct results in StructView.ConfigWidget happening, in which the reflect.Value of the struct is used to construct a widget structure with labels and values for the fields of the struct. The struct view and the widgets add events and styles functions to the widgets, which are then called in later event loop and style application passes. All of the content is later rendered to an image on the Scene, which is then pushed to the screen with Vulkan.

from core.

kkoreilly avatar kkoreilly commented on June 2, 2024

Can you try my new fix for this issue?

from core.

ddkwork avatar ddkwork commented on June 2, 2024

Sorry I just fell asleep for a while and it's 2:30 a.m. Thank you for the explanation of the reflection part. Also, I'm a little curious if you won't panic on your computer before this fix? Didn't you test? What's even stranger is that I didn't panic on my computer after running the core command for so long, perhaps for only one reason: except for this unit test scenario, all the core commands executed did not trigger names==0 to delete the slice member. It's just that when I execute the unit test, it crashes. In addition to this, the core command also has a warning under the giv package and exits, indicating that the field name is the same, which I guess is roughly the stake: the two fields of the struct have the same name. It should mean something similar.

from core.

ddkwork avatar ddkwork commented on June 2, 2024

from core.

ddkwork avatar ddkwork commented on June 2, 2024

from core.

ddkwork avatar ddkwork commented on June 2, 2024

Hello, I'm going to write an interface for ollama, but I don't know how to insert text into the text editing widget continuously without clearing the previous insertion, because the AI chat scene is the uninterrupted output of text, if the one-time output feels like the chat delay on a low-configuration device, so we need to support the stream feature, one input, streaming output. Is there a way to do this in the text editing widget?

ollama/ollama#2842

from core.

kkoreilly avatar kkoreilly commented on June 2, 2024

The response from the AI should not be in a text editor; it should be in a Label. You can just call Label.SetTextUpdate with the newly streamed text whenever you want to.

from core.

ddkwork avatar ddkwork commented on June 2, 2024

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.