https://linen.dev logo
Join Discord
Powered by
# haxe-ui
  • On threaded targets, call the events.progress thing. On other targets MainLoop.tick.
    p

    powerful-morning-89

    04/10/2023, 5:04 PM
    On threaded targets, call the events.progress thing. On other targets MainLoop.tick.
  • b

    bright-gpu-74537

    04/10/2023, 6:51 PM
    https://cdn.discordapp.com/attachments/565569107701923852/1095058599400701982/threaded-http.mp4
  • hl / heaps is interesting... seemed to by sync regardless
    b

    bright-gpu-74537

    04/10/2023, 6:52 PM
    hl / heaps is interesting... seemed to by sync regardless
  • noticable delay in UI responsiveness when its making http calls
    b

    bright-gpu-74537

    04/10/2023, 6:53 PM
    noticable delay in UI responsiveness when its making http calls
  • <@525025580106907659> - if you get five mins (and care), can you sanity check: https://github.com/core-haxe/http/blob/main/src/http/providers/DefaultHttpProvider.hx#L26-L93 - id be interested to know if you see any fuck ups 🙂
    b

    bright-gpu-74537

    04/10/2023, 6:57 PM
    @powerful-morning-89 - if you get five mins (and care), can you sanity check: https://github.com/core-haxe/http/blob/main/src/http/providers/DefaultHttpProvider.hx#L26-L93 - id be interested to know if you see any fuck ups 🙂
  • <@151104106973495296> - latest core/http should solve your problems
    b

    bright-gpu-74537

    04/10/2023, 6:57 PM
    @ambitious-knife-25690 - latest core/http should solve your problems
  • b

    bright-gpu-74537

    04/10/2023, 6:58 PM
    https://cdn.discordapp.com/attachments/565569107701923852/1095060224198582382/http-request-manager.zip
  • heres my test app for good measuer
    b

    bright-gpu-74537

    04/10/2023, 6:58 PM
    heres my test app for good measuer
  • > im not sure i follow, pass resolve to which thread? The thread which is gonna do the request and eventually send `resolve`/`reject`+the response back to the main thread.
    p

    powerful-morning-89

    04/10/2023, 7:23 PM
    > im not sure i follow, pass resolve to which thread? The thread which is gonna do the request and eventually send `resolve`/`reject`+the response back to the main thread.
  • you mean just: ```haxe sys.thread.Thread.createWithEventLoop(() -> { makeRequestCommon(request).then(response -> { resolve(...); }, error -> { ... }); }); ```
    b

    bright-gpu-74537

    04/10/2023, 7:24 PM
    you mean just:
    Copy code
    haxe
                sys.thread.Thread.createWithEventLoop(() -> {
                    makeRequestCommon(request).then(response -> {
                        resolve(...);
                    }, error -> {
                        ...
                    });
                });
  • pretty sure i had something similar before
    b

    bright-gpu-74537

    04/10/2023, 7:25 PM
    pretty sure i had something similar before
  • I mean something like this: ```hx enum WorkerResult { Success(resp:HttpResponse, resolve:HttpResponse->Void); Error(e:Any, err:Any->Void; } var deque = new sys.thread.Deque<WorkerResult>(); function makeThreadedRequest(request:HttpRequest):Promise<HttpResponse> { return new Promise((resolve, reject) -> { sys.thread.Thread.createWithEventLoop(() -> { makeRequestCommon(request).then(response -> { deque.push(Success(response, resolve)); }, error -> { deque.push(Error(error, reject)); }); }); }); } function onTimer() { var ready = []; while(true) { var o = deque.pop(false); if(o != null) ready.push(o) else break; } for (item in ready) { switch item { case Success(resp, resolve): resolve(resp); case Error(e, reject): reject(e); } } } ```
    p

    powerful-morning-89

    04/10/2023, 7:27 PM
    I mean something like this:
    Copy code
    hx
    enum WorkerResult {
      Success(resp:HttpResponse, resolve:HttpResponse->Void);
      Error(e:Any, err:Any->Void;
    }
    
    var deque = new sys.thread.Deque<WorkerResult>();
    
    function makeThreadedRequest(request:HttpRequest):Promise<HttpResponse> {
            return new Promise((resolve, reject) -> {
                sys.thread.Thread.createWithEventLoop(() -> {
                    makeRequestCommon(request).then(response -> {
                        deque.push(Success(response, resolve));
                    }, error -> {
                        deque.push(Error(error, reject));
                    });
                });
            });
        }
    
    function onTimer() {
            var ready = [];
            while(true) {
              var o = deque.pop(false);
              if(o != null) ready.push(o) else break;
             }
    
            for (item in ready) {
                switch item {
                  case Success(resp, resolve):
                    resolve(resp);
                  case Error(e, reject):
                    reject(e);
                 }
            }
        }
  • gotcha... yeah, cleaner for sure
    b

    bright-gpu-74537

    04/10/2023, 7:28 PM
    gotcha... yeah, cleaner for sure
  • If you have proper event loop integration you can even avoid the timer and deque and do ```hx function makeThreadedRequest(request:HttpRequest):Promise<HttpResponse> { return new Promise((resolve, reject) -> { var mainThread = Thread.current(); mainThread.events.promise(); sys.thread.Thread.createWithEventLoop(() -> { makeRequestCommon(request).then(response -> { mainThread.events.runPromised(() -> resolve(response)); }, error -> { mainThread.events.runPromised(() -> reject(error)); }); }); }); } ```
    p

    powerful-morning-89

    04/10/2023, 7:33 PM
    If you have proper event loop integration you can even avoid the timer and deque and do
    Copy code
    hx
    function makeThreadedRequest(request:HttpRequest):Promise<HttpResponse> {
            return new Promise((resolve, reject) -> {
                var mainThread = Thread.current();
                mainThread.events.promise();
                sys.thread.Thread.createWithEventLoop(() -> {
                    makeRequestCommon(request).then(response -> {
                        mainThread.events.runPromised(() -> resolve(response));
                    }, error -> {
                        mainThread.events.runPromised(() -> reject(error));
                    });
                });
            });
        }
  • yeah, i was actually looking to the remove the timer tbh, and figured the event loop impl was the way to go... just need to work out how thats gonna work in things like wx and raylib and make sure its not going to introduce some type of general perf penalty (i cant see why it would)
    b

    bright-gpu-74537

    04/10/2023, 7:34 PM
    yeah, i was actually looking to the remove the timer tbh, and figured the event loop impl was the way to go... just need to work out how thats gonna work in things like wx and raylib and make sure its not going to introduce some type of general perf penalty (i cant see why it would)
  • There will be a perf penalty if a lot of threads are trying to run events on the main thread's event loop at the same time, since you'll get lock contention. But in normal situations the overhead should be minimal.
    p

    powerful-morning-89

    04/10/2023, 7:38 PM
    There will be a perf penalty if a lot of threads are trying to run events on the main thread's event loop at the same time, since you'll get lock contention. But in normal situations the overhead should be minimal.
  • also, in this case it isnt alot of threads trying to do "something", its one callback checking the result of X threads, so im guessing it will be fine... if the callback is taking ages (for whatever reason) then that will hold everything up, but thats not different to the timer approach
    b

    bright-gpu-74537

    04/10/2023, 7:39 PM
    also, in this case it isnt alot of threads trying to do "something", its one callback checking the result of X threads, so im guessing it will be fine... if the callback is taking ages (for whatever reason) then that will hold everything up, but thats not different to the timer approach
  • alright, revised version: https://github.com/core-haxe/http/blob/main/src/http/providers/DefaultHttpProvider.hx#L23-L63
    b

    bright-gpu-74537

    04/10/2023, 7:40 PM
    alright, revised version: https://github.com/core-haxe/http/blob/main/src/http/providers/DefaultHttpProvider.hx#L23-L63
  • certainly simpler / more readable... thanks 🙂
    b

    bright-gpu-74537

    04/10/2023, 7:40 PM
    certainly simpler / more readable... thanks 🙂
  • I am passing an array data to a table column. I made custom renderer to convert array to vertical labels for each item in column data. This works fine in html5. With heaps target it throws error Can't cast hl.types.ArrayObj to enum<haxe.ui.util.VariantType> Called from haxe.ui.util._Variant.$Variant_Impl_.fromDynamic (haxe/ui/util/Variant.hx line 506) Called from haxe.ui.behaviours.Behaviour.setDynamic (haxe/ui/behaviours/Behaviour.hx line 28) Called from haxe.ui.behaviours.Behaviours.setDynamic (haxe/ui/behaviours/Behaviours.hx line 218)... Let me know if a sample project is needed. I dropping in a listview as renderer but it had same issue. FYI: haxe 4.3 not that likely matters
    p

    purple-businessperson-14467

    04/10/2023, 8:45 PM
    I am passing an array data to a table column. I made custom renderer to convert array to vertical labels for each item in column data. This works fine in html5. With heaps target it throws error Can't cast hl.types.ArrayObj to enum Called from haxe.ui.util._Variant.$Variant_Impl_.fromDynamic (haxe/ui/util/Variant.hx line 506) Called from haxe.ui.behaviours.Behaviour.setDynamic (haxe/ui/behaviours/Behaviour.hx line 28) Called from haxe.ui.behaviours.Behaviours.setDynamic (haxe/ui/behaviours/Behaviours.hx line 218)... Let me know if a sample project is needed. I dropping in a listview as renderer but it had same issue. FYI: haxe 4.3 not that likely matters
  • damn, I was feeling lazy
    p

    purple-businessperson-14467

    04/10/2023, 8:46 PM
    damn, I was feeling lazy
  • will do
    p

    purple-businessperson-14467

    04/10/2023, 8:46 PM
    will do
  • haha - fair dos - if you dont, then ill have to put myself in "Joe Mode" and recreate... ... ... one of us has to be Joe 😉
    b

    bright-gpu-74537

    04/10/2023, 8:47 PM
    haha - fair dos - if you dont, then ill have to put myself in "Joe Mode" and recreate... ... ... one of us has to be Joe 😉
  • ```hx Called from hxcpp::__hxcpp_main Called from sys.thread._Thread.Thread_Impl_::processEvents C:\HaxeToolkit\haxe\std/cpp/_std/sys/thread/Thread.hx line 62 Called from sys.thread.EventLoop::loop C:\HaxeToolkit\haxe\std/sys/thread/EventLoop.hx line 183 Called from haxe.MainLoop::tick C:\HaxeToolkit\haxe\std/haxe/MainLoop.hx line 172 Called from haxe.Timer::stamp haxe/Timer.hx line 30 Error : not implemented ```
    a

    ambitious-knife-25690

    04/10/2023, 10:24 PM
    Copy code
    hx
    Called from hxcpp::__hxcpp_main
    Called from sys.thread._Thread.Thread_Impl_::processEvents C:\HaxeToolkit\haxe\std/cpp/_std/sys/thread/Thread.hx 
    line 62
    Called from sys.thread.EventLoop::loop C:\HaxeToolkit\haxe\std/sys/thread/EventLoop.hx line 183
    Called from haxe.MainLoop::tick C:\HaxeToolkit\haxe\std/haxe/MainLoop.hx line 172
    Called from haxe.Timer::stamp haxe/Timer.hx line 30
    Error : not implemented
  • I get this when a timer is completed/cancelled and close the app but it might be an issue with std rather than haxeui
    a

    ambitious-knife-25690

    04/10/2023, 10:24 PM
    I get this when a timer is completed/cancelled and close the app but it might be an issue with std rather than haxeui
  • .... .... i should probably implement that, or as Zeta suggested, correct impl the event loop
    b

    bright-gpu-74537

    04/10/2023, 10:25 PM
    .... .... i should probably implement that, or as Zeta suggested, correct impl the event loop
  • anyways, bed now... i spent the WHOLE day on this, and i really should have just impl'd it correctly from the get go... c'est la vie
    b

    bright-gpu-74537

    04/10/2023, 10:26 PM
    anyways, bed now... i spent the WHOLE day on this, and i really should have just impl'd it correctly from the get go... c'est la vie
  • hey dude, do not worry, thank you so much for this
    a

    ambitious-knife-25690

    04/10/2023, 10:28 PM
    hey dude, do not worry, thank you so much for this
  • super appreciated!
    a

    ambitious-knife-25690

    04/10/2023, 10:29 PM
    super appreciated!
  • the error, at first glance, doesn't appear to be "breaking" either, it only happens when the app is closed
    a

    ambitious-knife-25690

    04/10/2023, 10:32 PM
    the error, at first glance, doesn't appear to be "breaking" either, it only happens when the app is closed
1...163116321633...1687Latest