Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.setTray crashing app on macOS Catalina 10.15.7 #615

Open
shalithasuranga opened this issue Sep 26, 2021 · 23 comments
Open

os.setTray crashing app on macOS Catalina 10.15.7 #615

shalithasuranga opened this issue Sep 26, 2021 · 23 comments
Labels
API bug Something isn't working hacktoberfest Global Hacktoberfest hackathon help wanted Extra attention is needed platform: Darwin

Comments

@shalithasuranga
Copy link
Member

Ref: #614

@alectrocute
Copy link

Also affecting macOS 12.1, FWIW.

@welljsjs
Copy link

welljsjs commented Feb 2, 2022

Not trying to be too impatient but is there any update on this as to what is the underlying issue?
Is there any workaround available?
Just causing us a little headache atm.

@Blatman
Copy link

Blatman commented Feb 3, 2022

Not sure if it will help but the os.setTray works for me on M1 Mac running Monterey 12.1 (Safari 15) (Rosetta2 installed).

Is there something in the setTray code causing the crash or is it a Catalina thing?

eg:
Using this code works OK -

Neutralino.init();
... whatever ...
if ((NL_OS == "Darwin") && ((NL_MODE == "window") || (NL_MODE == "chrome"))) {
window.myApp.setTray();
window.myApp.setWindowDraggable();
}

setTray: () => {
    if ((NL_MODE != "window") && (NL_MODE != "chrome")) {
        console.log("INFO: Tray menu is only available in the window or chrome mode.");
        return;
    }

    let tray = {
        icon: "/icons/trayIcon.png",
        menuItems: [
            {
                id: "VERSION",
                text: "Get version"
            },
            {
                id: "SEP",
                text: "-"
            },
            {
                id: "CHECKO",
                text: "Example: checked",
                isChecked: true
            },
            {
                id: "QUESTION",
                text: "Example: question"
            },
            {
                id: "DISABLED",
                text: "Example: disabled",
                isDisabled: true
            },
            {
                id: "NOTIFY",
                text: "Example: notification"
            },
            {
                id: "APID",
                text: "Example: App PID"
            },
            {
                id: "SEP2",
                text: "-"
            },
            {
                id: "QUIT",
                text: "Quit"
            }
        ]
    };
    console.log(Date.now() + ' - try setTray');
    var trayo = Neutralino.os.setTray(tray)
        .then(function (trayo) {
            console.log(Date.now() + ' - BINGO, setTray worked ', trayo);
        })
        .catch(function (err) {
            console.log(Date.now() + 'errSetTray', err);
        })
},

@welljsjs
Copy link

welljsjs commented Feb 3, 2022

It does not for me, but I'm on an Intel, not a M1 MB.

This is the relevant call stack:

--- STDERR ---
2022-02-03 11:06:31.095 neutralino-mac_x64[11816:165460] NSWindow warning: adding an unknown subview: <WKInspectorWKWebView: 0x7fa8e4f0c430>. Break on NSLog to debug.
2022-02-03 11:06:31.097 neutralino-mac_x64[11816:165460] Call stack:
(
        0   AppKit                              0x00007ff81a1a5dc6 -[NSThemeFrame addSubview:] + 112
        1   AppKit                              0x00007ff81a1a5b06 -[NSView addSubview:positioned:relativeTo:] + 203
        2   AppKit                              0x00007ff81a1a59be -[NSThemeFrame addSubview:positioned:relativeTo:] + 46
        3   WebKit                              0x00007ff91b7d00a5 _ZN6WebKit19WebInspectorUIProxy14platformAttachEv + 391
        4   WebKit                              0x00007ff91b8ea262 _ZN6WebKit19WebInspectorUIProxy4openEv + 84
        5   WebKit                              0x00007ff91bb126e6 _ZN6WebKit19WebInspectorUIProxy17didReceiveMessageERN3IPC10ConnectionERNS1_7DecoderE + 242
        6   WebKit                              0x00007ff91b47f21d _ZN3IPC18MessageReceiverMap15dispatchMessageERNS_10ConnectionERNS_7DecoderE + 199
        7   WebKit                              0x00007ff91b87afcb _ZN6WebKit15WebProcessProxy17didReceiveMessageERN3IPC10ConnectionERNS1_7DecoderE + 31
        8   WebKit                              0x00007ff91b45c9be _ZN3IPC10Connection15dispatchMessageENSt3__110unique_ptrINS_7DecoderENS1_14default_deleteIS3_EEEE + 634
        9   WebKit                              0x00007ff91b45c190 _ZN3IPC10Connection24dispatchIncomingMessagesEv + 408
        10  JavaScriptCore                      0x00007ff830d2ed4f _ZN3WTF7RunLoop11performWorkEv + 287
        11  JavaScriptCore                      0x00007ff830d2fcaa _ZN3WTF7RunLoop11performWorkEPv + 26
        12  CoreFoundation                      0x00007ff8177518fd __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
        13  CoreFoundation                      0x00007ff817751865 __CFRunLoopDoSource0 + 180
        14  CoreFoundation                      0x00007ff8177515e4 __CFRunLoopDoSources0 + 242
        15  CoreFoundation                      0x00007ff81775001b __CFRunLoopRun + 893
        16  CoreFoundation                      0x00007ff81774f5dd CFRunLoopRunSpecific + 563
        17  HIToolbox                           0x00007ff82038c4f1 RunCurrentEventLoopInMode + 292
        18  HIToolbox                           0x00007ff82038c247 ReceiveNextEventCommon + 587
        19  HIToolbox                           0x00007ff82038bfe5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
        20  AppKit                              0x00007ff81a17ed88 _DPSNextEvent + 886
        21  AppKit                              0x00007ff81a17d3f4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1411
        22  AppKit                              0x00007ff81a16f919 -[NSApplication run] + 586
        23  neutralino-mac_x64                  0x000000010cd4cdb1 _ZN7webview22cocoa_wkwebview_engine3runEv + 165
        24  neutralino-mac_x64                  0x000000010cd4e416 _ZN6window11controllers14__createWindowEv + 567
        25  neutralino-mac_x64                  0x000000010cd4fd8f _ZN6window11controllers4initERKN8nlohmann10basic_jsonINSt3__13mapENS3_6vectorENS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEbxydS9_NS1_14adl_serializerENS5_IhNS9_IhEEEEEE + 1069
        26  neutralino-mac_x64                  0x000000010cd00e6a _Z10__startAppv + 635
        27  neutralino-mac_x64                  0x000000010cd01900 main + 172
        28  dyld                                0x00000001139d44fe start + 462
)

--- STDOUT ---

@Blatman
Copy link

Blatman commented Feb 3, 2022

Looks like an Intel only issue then although Rosetta2 should react the same ....

@Blatman
Copy link

Blatman commented Feb 21, 2022

Was kind of curious as to where the above call stack was coming from and I get it whenever I open the Inspect Element dev console after the app has launched (double-clicking executable) - this occurs even if the previous code (setTray or extn code) has worked successfully or not. I will get these logs in this scenario on 12.2 Monterey back to 10.13 High Sierra. If the executable is packaged as a normal mac app (exec is in MacOS folder/ app files in Resources folder) and launched normally there is no problem.

@welljsjs
Copy link

Yeah sorry about that I think the above call stack is indeed unrelated to the actual issue with setTray

... and launched normally there is no problem.

Now you're referring to setTray or the warning from above?

@Blatman
Copy link

Blatman commented Feb 22, 2022

Yea - the warning above only occurs when the dev tools are opened (WKInspectorWKWebView) when using the executable directly in terminal mode.
The setTray works for me OK but the original code for this issue failure is not available so don't know the story there and I don't have Catalina to try it on. Must be a curly one since it has gone to GSOC!

@richb-hanover
Copy link

richb-hanover commented Mar 13, 2022

This still seems to be a problem with the First Neutralinojs App (macOS 10.15.7, Intel MacBook Pro). I get neutralino-mac_x64 was stopped with error code null when calling setTray() (The call to setTray() is still commented out in the starter app.)

I just tested with Neutralino Server 4.4.0, Client 3.3.0 (build from a couple days ago). Using the documented procedure for creating the First Neutralino App, neu run looks and works OK: It opens the expected window (below), if I bring another app to the front, clicking the tray/dock icon brings the starter app back to the front, clicking the red dot (upper left) quits the application with "success code 0" as expected.

# THIS WORKS
√ firstneuapp % neu run
Starting process: neutralino-mac_x64  --load-dir-res --path=. --debug-mode
devAPIServer listening at http://localhost:5050
neutralino-mac_x64 was stopped with success code 0

image

BUT... Changing the starter app code to call setTray() (comment out the if statements on lines 59 & 61 of main.js) I see the error code null message (below)

# THIS FAILS WHEN setTray() IS CALLED
√ firstneuapp % neu run
Starting process: neutralino-mac_x64  --load-dir-res --path=. --debug-mode
devAPIServer listening at http://localhost:5050
neutralino-mac_x64 was stopped with error code null

What other information could I collect? Thanks

@richb-hanover
Copy link

Update: neu build --release from the same directory as the prior report gives the following crash:

√ firstneuapp % neu build --release
Bundling app...
Generating res.neu...
Copying binaries...
Error: ENOENT: no such file or directory, stat 'bin/neutralino-linux_ia32'
    at Object.statSync (fs.js:1042:3)
    at Object.statSync (/Users/richb/.config/yarn/global/node_modules/graceful-fs/polyfills.js:311:34)
    at statSync (/Users/richb/.config/yarn/global/node_modules/@neutralinojs/neu/node_modules/fs-extra/lib/util/stat.js:10:52)
    at getStatsSync (/Users/richb/.config/yarn/global/node_modules/@neutralinojs/neu/node_modules/fs-extra/lib/util/stat.js:24:19)
    at Object.checkPathsSync (/Users/richb/.config/yarn/global/node_modules/@neutralinojs/neu/node_modules/fs-extra/lib/util/stat.js:49:33)
    at Object.copySync (/Users/richb/.config/yarn/global/node_modules/@neutralinojs/neu/node_modules/fs-extra/lib/copy-sync/copy-sync.js:24:38)
    at Object.module.exports.bundleApp (/Users/richb/.config/yarn/global/node_modules/@neutralinojs/neu/src/modules/bundler.js:38:21)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Command.<anonymous> (/Users/richb/.config/yarn/global/node_modules/@neutralinojs/neu/src/commands/build.js:11:13) {
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path: 'bin/neutralino-linux_ia32'
}
  _   _            _             _ _             _
 | \ | | ___ _   _| |_ _ __ __ _| (_)_ __   ___ (_)___
 |  \| |/ _ \ | | | __| '__/ _` | | | '_ \ / _ \| / __|
 | |\  |  __/ |_| | |_| | | (_| | | | | | | (_) | \__ \
 |_| \_|\___|\__,_|\__|_|  \__,_|_|_|_| |_|\___// |___/
                                              |__/
Please check the ./dist directory!
√ firstneuapp %

@richb-hanover
Copy link

@shalithasuranga Why would a macOS build try to include bin/neutralino-linux_ia32? (see above) Thanks.

@Blatman
Copy link

Blatman commented Mar 13, 2022

Just for curiosity does anyone have an example of code within the setTray() function that fails or does it only fail when using the CLI? eg: I do know that if say the icon path option is unavailable or misspelt then the app will crash with a segmentation trap.

@pegvin
Copy link
Contributor

pegvin commented Mar 13, 2022

Segmentation fault means it's a problem inside the Neutralino C++ Code itself and not the client file

@Blatman
Copy link

Blatman commented Mar 13, 2022

Yes that may be the case. As far as I can see for me the setTray works OK in a normal mac app scenario provided the icon path etc is OK but it appears that the issue may be occurring if the CLI is being used. I have noticed that even with the CLI if the icon path is not right then a crash will occur.

Update: just tried the latest CLI (9.2.0 with server 4.4.0 and client 3.3.0) on 10.13 and 12.2 M1 and setTray() works well for me - I was using npx to create/build/run as I don't like global installs so maybe there is an issue only with the global install on M1's.

@wobsoriano
Copy link

If it helps, this currently works on Monterey 12.3

@adomas000
Copy link

Any workarounds for this or ETA for when this will be fixed? 😢

@denisw
Copy link
Contributor

denisw commented Oct 17, 2022

If the issue is a segfault, then you could perhaps try if #1010 fixes the issue. It adapts to changes to the objc_msgSend function signature by explicitly casting all uses of objc_msgSend to the matching function type, which ensures that the parameters are passed exactly as expected. (Despite the PR title, this change can be relevant to both Intel and Apple Silicon.)

@brandon-kyle-bailey
Copy link

Any updated on this? Been open for a while by the looks of it

@kwiateusz
Copy link

It's still not working on Ventura 13.2 and neutralinojs 4.11.0, any clues to fix that?

@richcouzzi
Copy link

richcouzzi commented Apr 28, 2023

On a M1 MPB with Monterey v 12.6 - I commented-out the conditional check if(NL_OS != "Darwin") in the main.js file created by neu create. I am able to confirm the setTray() call does work, and without crashes or error.

Edit: Since the starter app code links to this issue in a comment, It might be helpful for the conditional check to more specifically look for the affected macOS version. The demo example, as is, gives the impression—to folks going through the "Your First Neutralinojs App" journey—that os.SetTray doesn't work at all on macOS.

@ashishkpoudel
Copy link

ashishkpoudel commented Jul 7, 2023

This issue also exists on Ubuntu 22.04. I'm using os.setTray from @neutralinojs/lib. However the boilerplate project with neutralino.js works.

neutralino-linux_x64: lib/json/json.hpp:19306: const value_type& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::operator[](T*) const [with T = const char; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector<unsigned char>; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::const_reference = const nlohmann::basic_json<>&; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::value_type = nlohmann::basic_json<>]: Assertion `m_value.object->find(key) != m_value.object->end()' failed.

@Aeiddius
Copy link

Aeiddius commented Oct 1, 2023

any news?

This was referenced Nov 25, 2023
@OrigamingWasTaken
Copy link

Re-asking if any workaround was found?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API bug Something isn't working hacktoberfest Global Hacktoberfest hackathon help wanted Extra attention is needed platform: Darwin
Projects
None yet
Development

No branches or pull requests