Several newb questions (state, bind, win on macOS)

Hi,
Some years ago, I enjoyed developing a small fan game based on Haxe/OpenFL.
So, when a mission requested a desktop, I took the opportunity to get back to Haxe with HaxeUI-hxWidgets this time.

After some hours lost with vscode, project template and others hxwidget issue, I’m finally ready to develop my app.

And so came the first questions :smile:

  1. How do you handle multi “steps”/states ?
    Let’s take a wizard for exemple, how do you handle screen1 then screen2 … ?
    I tried with addComponent, button.click, removeComponent/addComponent but it crashes with segfault 11 on MacOS :
    It seems I can’t remove a component from within a listener to an event dispatched by the component’s child.
    So I used the hide/show method, but I fear it consumes too much memory …
    What is the best approach ?

  2. Does @:bind(component, MouseEvent.CLICK) use registerEvent or onClick ?
    From what I understand here, registerEvent allows multiple listeners so I’d like to use the right way to register to an event

  3. Compile a Windows app on MacOS
    Is it possible to compile a Windows desktop app on MacOS ? it seems no, but since there is a lot of hidden feature, post or tricks, I ask

Regards

1 Like

Hi there!

So ill just answer your question as you asked them :slight_smile:

  1. This sounds like a bug. Can you create a minimal sample and add it to haxeui-hxwidgets? I would probably be using add/removeComponent also, so something is wrong with it. Im sure i must have removed a component on hxwidgets (mac, windows and linux), so its either a) something special in your setup b) something strange in your app or c) a new bug / regression introduced - regardless it would be be good to fix it as its pretty important to be able to remove components! :smiley:

  2. @:bind uses registerEvent, correct - and exactly as you say, registerEvent allows multiple listeners.

  3. I think there may be away, but i dont know if it, and personally, havent done it. The easiest way (i would guess) would be to get windows running in a virtual machine.

I hope that helps somewhat, and defo let me know about #1… thanks!

Ian

Thanks Ian

Basic crashing sample (hello_hx_macos.zip) is available on https://filebin.net/kdu96jpgr6j5ykhl
I hope I didn’t make something stupid

Regards

If it could help, if I use a Box and not a raw Component, I have another error:

../include/wx/vector.h(488): assert "idx < m_size" failed in at().

Regards

OK, ive had a quick look and something defo seems up:

image

Which is the exact same error, so thats “good”… I wonder if its something about the way you are using events. Ill investigate a little and let you know.

Cheers!
Ian

OK, so this worked:

        var button = new Button();
        button.text = "Test2";
        addComponent(button);
        button.onClick = function(e) {
            this.removeComponent(screen1);
        }

So it is something with the events… that said, it does look valid to me, so its worth fixing.

So, actually there was a bug, but it only happened when you destroy something that was still processing events. In this case, you click a button and that removes a view that contains it, so that exposed this 2 part issue. First was a bug in haxui-core and second was in hxWidgets. These should be fixed now - so you’ll need git versions of each lib (lemme know if you dont know how to do that)

All in all a great find!

Cheers!
Ian

Great, happy to have sort of help haxeui.

I’ll try to find again how to set a git/dev haxelib.
I did it years ago, it should come back :slight_smile:

May I open a new post for more question or should I edit this one?

New threads might be easier - just for context

Ian

it seems that the crash which occurs when I remove a component is back.
But it’s not the same because it’s harder to reproduce…
still a segfault 11, but only on some cases.
I suspect it related to garbage collector because I do something like

currentComponent = new myBox1();
currentComponent.registerEvent(xxxx, onevent);
addComponent(currentComponent);

onEvent(e)
    removeComponent(currentComponent)
    currentComponent.unregisterEvents();
    currentComponent = null;
    currentComponent = new myBox2();
    addComponent(currentComponent);

=> segFault11 on refresh screen

How could I debug my code > haxeui-core > native backend so I could point on the issue ?

The best bet is to just try and reduce it to a super minimal example, then you can try and find what is the cause (or i can)… Its a lot of trial and error :slight_smile:

You can use VSCode i think to debug hxcpp, but ive never had much luck with it (though i havent tried in a while).

Let me know if you manage to create a super minimal example.

Cheers,
Ian

I found the culprit : ListView.
It crashes if the component you want to remove include a listview

You can see it on https://bitbucket.org/WillNa/haxeui-bugs/, bug 2 and 8

(for HXCPP debug, I tried hard for 2hours without success…currently looking for more details on vscode .json file, I don’t understand how task and launch works together)

Still trying to find the root cause.
I was finally able to get more than a poor ‘segment fault : 11’ on terminal.

Again related to event, but I need to find more to be able to share a minimal example to produce the crash

I found it to crash if I have 42 components or more on a vbox
At 41, it no longer crashes…

I still need to understand if it’s because of the height of stage or the number of components…
Simple exemple to reproduce crash coming soon.

EDIT : no problem on a basic sample…I need to find what happen first on my app which make the 42th component crashed the app. It’s not related to number of components but a memory error probably. Definitely related to event+rev, but I don’t know how exactly for now.

App no longer crashes if I comment a line in Component.hx

        if (dispose == true) {
            child._isDisposed = true;
            //child.removeAllComponents(true);
            child.unregisterEvents();
            child.destroyComponent();
        }

so I assume one child is the culprit, but whatever I did, it’s when I add any more component that it crashes.
It drives me insane!

EDIT : replaced with

            child.removeAllComponents(false); 

same crash

So I rebuilded my project with -debug and the crash is different

Unhandled unknown exception; terminating the application.
Abort trap: 6

I still don’t see why…
I tried to load the Component that crash on startup

      app.ready(function() {
            app.addComponent( new CrashingView() );
            app.start();
        }); 

no problem!!!

So it comes from what happen BEFORE I load it

Can you attache a test app?

EDIT: ah, bugs 2 & 8 correct?

Cheers,
Ian

unfortunately no.
I’m unable to create a test app, while, trust me, I tried!
It only crashes on my case, so I’ll try to anonymize (NDA product so :hot_face:) part of my app which crashes

EDIT : so I did it…it crashes on my app, it doesn’t on my bugssample app :hot_face:

I made it!!!
I made it crashes::
It’s the first time in ages I’m happy to (re)produce a crash!

What is VERY strange is the crash occurs only if my component is the first added to the HaxeUIApp.
Please look for comment added on Main.hx
https://bitbucket.org/WillNa/haxeui-bugs (bug10)

1 Like

Great! Thanks, ill be looking at these issues “soon” (other things keep coming up)… but thanks for the repro!

Cheers,
Ian