arduino / Arduino

Arduino IDE 1.x
https://www.arduino.cc/en/software
Other
14.17k stars 7.02k forks source link

Menu don't show up in OSX High Sierra Menubar #6548

Closed guidefreitas closed 7 years ago

guidefreitas commented 7 years ago

Menu don't show up in OSX High Sierra menubar.

S.O.: OSX High Sierra Beta 4

facchinm commented 7 years ago

Thanks a lot for reporting! Could you debug the problem a bit while we setup a Mac with that OS version? Launching the IDE via commandline and pasting here the output would be enough. To launch the IDE simply execute /Applications/Arduino.app/Contents/MacOS/Arduino in a Terminal and any error should appear there. Thanks again!

cmaglie commented 7 years ago

and here we go again... :-)

guidefreitas commented 7 years ago

Hi. Thanks for the fast feedback. Here is the log.

Last login: Tue Jul 25 00:26:48 on ttys000 ➜ ~ /Applications/Arduino.app/Contents/MacOS/Arduino [JmDNS(fe80-0-0-0-aede-48ff-fe00-1122-en5.local.).Timer] WARN javax.jmdns.impl.tasks.resolver.DNSResolverTask - ServiceResolver(fe80-0-0-0-aede-48ff-fe00-1122-en5.local.).run() exception java.io.IOException: No route to host (sendto failed) at java.net.PlainDatagramSocketImpl.send(Native Method) at java.net.DatagramSocket.send(DatagramSocket.java:693) at javax.jmdns.impl.JmDNSImpl.send(JmDNSImpl.java:1595) at javax.jmdns.impl.tasks.resolver.DNSResolverTask.run(DNSResolverTask.java:74) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) [fe80-0-0-0-aede-48ff-fe00-1122-en5.local..recover()] WARN javax.jmdns.impl.JmDNSImpl - RECOVERING [JmDNS(fe80-0-0-0-aede-48ff-fe00-1122-en5.local.).State.Timer] WARN javax.jmdns.impl.tasks.state.DNSStateTask - Canceler(fe80-0-0-0-aede-48ff-fe00-1122-en5.local.).run() exception java.io.IOException: No route to host (sendto failed) at java.net.PlainDatagramSocketImpl.send(Native Method) at java.net.DatagramSocket.send(DatagramSocket.java:693) at javax.jmdns.impl.JmDNSImpl.send(JmDNSImpl.java:1595) at javax.jmdns.impl.tasks.state.DNSStateTask.run(DNSStateTask.java:131) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) [fe80-0-0-0-aede-48ff-fe00-1122-en5.local..recover()] WARN javax.jmdns.impl.DNSStatefulObject$DefaultImplementation - Wait for canceled timed out: DNS: fe80-0-0-0-aede-48ff-fe00-1122-en5.local. [fe80:0:0:0:aede:48ff:fe00:1122%en5/fe80:0:0:0:aede:48ff:fe00:1122%en5] state: canceling 1 task: null [fe80-0-0-0-aede-48ff-fe00-1122-en5.local..recover()] WARN javax.jmdns.impl.JmDNSImpl - fe80-0-0-0-aede-48ff-fe00-1122-en5.local.recover() Could not recover we are Down!

naturfenomen commented 7 years ago

I'm on High Sierra public beta 3 and i's the same problem for me - i.e. no menu except for 'Arduino'. But no error when starting from Terminal.

facchinm commented 7 years ago

Also reported here and here. It looks like this problem affects all Java8 programs, so it's very likely to be solved by Apple in one of the next betas. Keeping the issue open to track the issue anyway

cstatz commented 7 years ago

This is still an issue for Public Beta 4!

jaxxon33 commented 7 years ago

Same issue with Developer Beta version 5, Aug 9 2017.

facchinm commented 7 years ago

Argh, this is bad...

optikfluffel commented 7 years ago

As a workaround for now you could install the legacy Java 6 runtime.

jaxxon33 commented 7 years ago

I have 2 MacBooks running High Sierra, one has Java 8 Update 121 and works fine with Arduino IDE, the other has Update 144 (currently latest) and has the 'no menu' problem.

vgiffin commented 7 years ago

I saw this on Beta 3 (17A306f), but not on Beta 4 (17A315i) or later.

ghost commented 7 years ago

Still on developer beta 9 (17A360a) with Java 8 Update 144...

xDuk3x commented 7 years ago

Same Error on Golden Master (17A362a) with Java 121 & 144

facchinm commented 7 years ago

Adding other resources: https://youtrack.jetbrains.com/issue/JRE-434#comment=27-2424694 https://bugs.eclipse.org/bugs/show_bug.cgi?id=520176

Trying to implement something similar to https://git.eclipse.org/r/#/c/105553/ and post a PR soon

facchinm commented 7 years ago

Modifying Info.plist has no effect on OSX High Sierra GM . Following the discussion on Eclipse bugtracker, it looks like SWT has just been patched to overcome a bug in the latest OSX builds (DefaultApp.nib only present in /System/Library/Frameworks/JavaVM.framework/Versions/A/Resources/en.lproj folder) see https://git.eclipse.org/r/#/c/105582/

to sum up:

In the meantime, let's use this thread to report any improvement.

McAlb commented 7 years ago

I have just installed the brand spanking and official new High Sierra release. Menu bar is still not working. Changing the language to english works....

puybaret commented 7 years ago

You could set apple.laf.useScreenMenuBar property to true only if the current system is not macOS 10.13 and the application menu isn't empty. Something like:

System.setProperty("apple.laf.useScreenMenuBar",
   String.valueOf(!System.getProperty("os.version").startsWith("10.13")
        || com.apple.eawt.Application.getApplication().isAboutMenuItemPresent()));

This is the solution I programmed in Sweet Home 3D. At least, the menu bar appears at the top of the window the time that Apple fixes the bug (just copy the DefaultApp.nib file of your locale from a previous macOS version and you'll see that the menu bar will go back to the screen menu bar, except if Apple decides to fix this issue another way). Note that isAboutMenuItemPresent was removed under Java 9, where you should rather call Desktop.isSupported(Desktop.Action.APP_ABOUT) (you may also program that statement with reflection if needed)

facchinm commented 7 years ago

@puybaret , doesn't apple.laf.useScreenMenuBar need to be set before the GUI thread is spawned? Anyway, thanks for the tip, trying right now

puybaret commented 7 years ago

It's not because you have to set this property before playing with Swing, that it cannot be set at the beginning of the program execution.

facchinm commented 7 years ago

Here's the PR https://github.com/arduino/Arduino/pull/6763 I only tested it briefly on my colleague's OSX but I couldn't reproduce the issue (I should have rebooted probably, will try later). In the meantime, the build from the PR should be ready in 20 minutes, if anyone can test it it would be great.

puybaret commented 7 years ago

Be sure to test on a system that doesn't use English as primary language

facchinm commented 7 years ago

Sure, I changed the language to Italian but I didn't reboot, and the menus still appeared on a 10.13 final. Checking after a reboot later today. In the meantime, if you could test http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-6763-BUILD-727-macosx.zip it would be supernice

McAlb commented 7 years ago

I have just toggled back to german on PR-6763. Didn´t work... :-(

facchinm commented 7 years ago

New build http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-6763-BUILD-728-macosx.zip

felixerdy commented 7 years ago

Build 728 still does not work on my system, language is german 😕

haciendalabs commented 7 years ago

Hello, build 728 don't work here.french system.

facchinm commented 7 years ago

Last surprise of the day, will continue tomorrow for the fix: setting apple.laf.useScreenMenuBar= false in the build.txt has no effect either, but launching via CLI using system java and CLASSPATH brings the menus back in ANY language. So tomorrow debugging session will be on Appbundler. Thanks everyone for testing, the [HELP WANTED] tag is still valid so if anyone can contribute with code and trials it would be supercool. Thanks again

Gohstgamer commented 7 years ago

To all those who can't wait until an update fixes the bug, I have a work around:

  1. Shutdown your Mac
  2. Start in recovery mode and open the terminal then, type "csrutil disable" (else you can't write in the /System folder)
  3. Restart
  4. Go to "/System/Library/Frameworks/JavaVM.framework/Versions/A/Resources/en.lproj"
  5. Copy the file named "DefaultApp.nib"
  6. Go to "/System/Library/Frameworks/JavaVM.framework/Versions/A/Resources/[your prefered language].lproj"
  7. Paste "DefaultApp.nib"
  8. Move the "Menu.strings" from you prefered language folder to another folder (for eg. create an "Java [your language].lproj" in your document folder), so you can restore all changes if you want to
  9. Restart your System

Now Arduino should work again as it did, at least it worked for me as I placed the "DefaultApp.nib" into the "German.lproj" and deleted there "Menu.strings".

This worked for me, that doesn't mean it has to work for all of you or that's impossible something fails due to these changes. Do this at your own risk!

GaelC92 commented 7 years ago

Since it seems related to the language and country selection, it might help to use java switches java -Duser.language=en -Duser.country=US -Duser.variant=US -jar ... to enforce locale settings. Unfortunately I'm unable to test, since I'm not sure which jar file / class should be called from CLI. Any hint ?

facchinm commented 7 years ago

Hi @GaelC92 , thanks for the tip, unfortunately enforcing the locale via java switches doesn't solve the issue, probably due to AppBundler Sample patch:

diff --git a/build/build.xml b/build/build.xml
index d95f8def6..b45dff0f7 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -411,6 +411,9 @@
       <option value="-Dcom.apple.smallTabs=true"/>
       <option value="-DAPP_DIR=$APP_ROOT/Contents/Java"/>
       <option value="-Djava.ext.dirs=$JVM_RUNTIME/Contents/Home/lib/ext/:$JVM_RUNTIME/Contents/Home/jre/lib/ext/"/>
+      <option value="-Duser.language=en"/>
+      <option value="-Duser.country=US"/>
+      <option value="-Duser.variant=US"/>

       <!--
       <option value="-Dapple.awt.showGrowBox=false"/>
GaelC92 commented 7 years ago

It may be necessary to pass LANG environnement vars as well... This is a workaround, but if somehow we manage to setup the JVM to use en_US locale, it should show the menu, according to the previous comments. So it's just a matter of how :)

GaelC92 commented 7 years ago

@facchinm could you provide me the main class name to launch the GUI (from CLI)? (I'm struggling to find it within the code, since I'm new to it)

facchinm commented 7 years ago

The main class is Processing.app.Base; I'm trying to set LANG from Info.plist right now, will report back as soon as I have any result.

GaelC92 commented 7 years ago

@facchinm Got it working !! Here is how I managed to get the menus from CLI 1) export _JAVA_OPTIONS=" -Duser.language=en -Duser.country=US -Duser.variant=US -Duser.region=US " (this enforces the java settings for each jvm / java tools and has priority over anything else. Alternatively one can use JAVA_TOOL_OPTIONS, but this is lower priority than any other mean to set these values) 2) call the Base class this way (from the Java directory in the package) : LANG=en java -cp "arduino-core.jar:./*" processing.app.Base

Update : It is also possible to use only inline env variables, to avoid messing with other java apps. Just start terminal and use

cd /Applications/Arduino.app/Contents/Java _JAVA_OPTIONS=" -Duser.language=en -Duser.country=US -Duser.variant=US -Duser.region=US " LANG=en java -cp "arduino-core.jar:./*" processing.app.Base

Using the launcher (MacOs/Arduino) doesn't work – I assume it does some environment variables rewriting before it calls the main class

GaelC92 commented 7 years ago

As a temporary in-code workaround, you could maybe set the above variables at launch, conditioned on the JVM/OS version, and/or a preference setting ?

facchinm commented 7 years ago

I just pushed another couple of patches on https://github.com/arduino/Arduino/pull/6763; newer appbundler allows setting environment variables via Info.plist, let's hope it's enough to workaround the issue

facchinm commented 7 years ago

New build: http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-6763-BUILD-729-macosx.zip

GaelC92 commented 7 years ago

nope. the new build does not fix the problem.

GaelC92 commented 7 years ago

@facchinm
Ok. Funny enough, the following command line does work, and displays the menu in french ! : _JAVA_OPTIONS=" -Duser.language=fr -Duser.country=FR -Duser.variant=FR -Duser.region=FR " LANG=fr java -cp "arduino-core.jar:./*" processing.app.Base

So it seems that at some point, the locale are removed or badly passed to the JVM, and forcing them does fix the problem.

GaelC92 commented 7 years ago

hmm... not sure what happened but now, I can simply call java -cp "arduino-core.jar:./*" processing.app.Base" and it does work...

facchinm commented 7 years ago

I've finally been able to find where the global menubar was being set forcefully; integrating it with @puybaret instructions gave the correct result (eg. the Windows-style workaround). Build from @ArduinoBot is coming

facchinm commented 7 years ago

Here we go again http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-6763-BUILD-731-macosx.zip

facchinm commented 7 years ago

image Ugly but at least usable

McAlb commented 7 years ago

yeah! You did it, it works. In my case in german... Thanks!!

GaelC92 commented 7 years ago

For what it's worth, here is what I obtain from the previous (without the latest patch) version when calling from command line. This hints that the problem probably does neither lie within JRE nor within the application code. I believe it's the appbundler but I cannot find what it does to make the menu fail. @facchinm , maybe you could spot a difference in the env vars or java settings passed to the main class at startup ? (I could not until now)

capture d ecran 2017-09-27 a 18 04 31
facchinm commented 7 years ago

I just merged the patch on master so it would be supercool if you could test the hourly build as soon as it's ready. If everything is ok we can release soon and provide a workaround for all mac users willing to update. Thanks everyone for the help.

McAlb commented 7 years ago

hourly build works like PR-6763-BUILD-731 - this time with german menus

McAlb commented 7 years ago

right! it really seem to be a java-issue

AdrianBuza commented 7 years ago

I found a simpler workaround. Force the language to English for the .app. Open a Terminal and run: defaults write cc.arduino.Arduino AppleLanguages '(en)'

manolivette commented 7 years ago

La solution de AdrianBuza ok pour moi.