jacksondunstan / UnityNativeScripting

Unity Scripting in C++

Home Page:https://jacksondunstan.com/articles/3938

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Need merge back feature]Frequently crash with memory linkedlist

sekkit opened this issue · comments

image

If i do not call addcomponent, it worked well.
But when I addcomponent(a monobehaviour added to scene), and stop playing, and replaying, this issue will ocur.

IT is confirmed that using your MonoBehaviour Messages old tree's code.
No longer crashes. But the feature & bugfixes seemed to be hard to merge back due to API's breaking change...

With the latest master version, the CodeGen cannot generate from the config file attached below .. seems the compatibiliy was broken (feature lost) since your <Commits on Mar 12, 2018>
NativeScriptTypes.zip
lost)

If i do not call addcomponent, it worked well.
But when I addcomponent(a monobehaviour added to scene), and stop playing, and replaying, this issue will ocur.

I haven't noticed any crash when stopping playing on Windows, at least with the example in the repo. Can you please describe more about your testing environment and the changes you made to the repo to get the crash to happen?

IT is confirmed that using your MonoBehaviour Messages old tree's code.
No longer crashes. But the feature & bugfixes seemed to be hard to merge back due to API's breaking change...

With the latest master version, the CodeGen cannot generate from the config file attached below .. seems the compatibiliy was broken (feature lost) since your <Commits on Mar 12, 2018>
NativeScriptTypes.zip
lost)

Can you be more specific than "your MonoBehaviour Messages old tree's code"? For example, which commit introduced the issue? Even better would be to tell me specifically what the issue is, ideally in the form of a PR that fixes it. :)

In this commit you deleted the obsolete implementation of MonoBehaviour. Using Generic BaseType way instead.
That caused the problem. I have trouble re-merge that deleted code back cause lot of things changed.
The error stack shows the BaseBallScript object has bugs in memory management. Null pointer I guess.
Since this commit as the picture shows^^
(PS: I'm using python binding against UnityNativeScript, and your Old implementation is totally working. Maybe I can mail you the DEMO project to debug)
image

Thanks for pointing out the offending commit. That corresponds to this article that details how the new functionality works and how it's much more featureful than the MonoBehaviour-specific functionality that was replaced. The project won't go back to the old way, but I'm interested in fixing bugs in the new way.

I received your example project but wasn't able to reproduce the issue. Here's what I did:

  1. Opened the project in Unity 2018.4.3f1 (instead of 2018.4.5f1, but the difference is minor)
  2. Opened Terminal and ran cd /path/to/project/Libs then sh gen_all.sh. Apparently everything successfully built.
  3. Switched to startup_scene
  4. Entered play mode
  5. Clicked the Button. Nothing apparently happened.
  6. Exited play mode
  7. Repeated steps 4-6 five times
    8 Switched to BootScene
  8. Entered play mode
  9. Received an error: Exception: Couldn't open native library: /path/to/project/Assets/Plugins/Editor/NativeScript.bundle/Contents/MacOS/NativeScript

Please let me know what I should do differently to reproduce the issue.

Plz check my mail for a well configured OSX project. along with detailed steps to configure the project.

Finally u just run ln -s Scripts to Assets/StreamingAssets/Scripts to enable python scripts to be found...

now it runs

To summarize some e-mail threads with @sekkit: the provided project couldn't be made to work with a reasonable level of effort due to considerable issues configuring it. Please provide a test project that doesn't require configuration, such as by tweaking the code in the repro to show the issue.

Hi, i already give your the approach to do that.
Way 1:
drag the xcodeproject file(that very single file) to VSCode.
search /Users/xxxx
replace with your real path
DONE

coz it's configured with CMake, so i reckon it's the only way to make it work on your environment.
This code is definitely tweaked from your code, even the CMakeFileList.txt, only added few lines...

OR:
please provide me with your localpath, the path you put my project.
I will modify it and resend to you^^

If I were you, troubled by xcode, whatever issue it is.
I will USE a Windows PC to get rid of that configuration...basically no config stuff needed

I believe I've found the source of the issue. BootScript.OnApplicationQuit was being called before your OnDestroy function. This caused your OnDestroy to try to call into the native library after it was closed by BootScript.OnApplicationQuit.

I just pushed 74d7d4a which replaces BootScript.OnApplicationQuit with listening to EditorApplication.playModeStateChanged for when the state returns to PlayModeStateChange.EnteredEditMode. This seems to only happen after OnDestroy messages are sent to each MonoBehaviour, so the native library won't be closed while you're handling that message.

great!