Cocoa Application not working from bundle. lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- Josh · 2018-09-12 19:13 Hi I have an application that runs fine in carbon, and now compiles for x-64 for cocoa. The application runs if I run the executable direct from Finder, if I create an application bundle using Lazarus then I do not get a display ( just 99.99% cpu usage) this has the link back to executable. If I replace the Link in the Bundle with the execuatble, I get the same problem. If I create the same app for carbon, the application works from Finder and also from bundle whether linked or not. Any ideas what I am doing wrong ? ---------------------------------------------------------------------- skalogryz · 2018-09-12 19:43 Why don’t you share the project? This page should help you with that. ---------------------------------------------------------------------- Josh · 2018-09-13 22:34 Hi I am in the proces of minimizing; which includes removing own components and non-sharable code, whilst keeping the probem intake. Taking some time as its quite a large project. Some other observations, I can run the application thats in the bundle macos folder, either as the shortcut or as the executeable; but not the bundle itself. Which kind of points to a problem with the bundle. Additional Observation, its as though the application is not showing the main form when run within bundle, as when I monitor Application with activity Monitor, the application is increasing and decreasing the CPU as the application normally does during a normal run, just no display.. ---------------------------------------------------------------------- Josh · 2018-09-17 15:30 Hi Done some further test, i created a multiform project, and then put a showmessage in formactivate event; the app runs ok when executable is run, but if you create a bundle and try the bundle then it crashes. ---------------------------------------------------------------------- skalogryz · 2018-09-17 17:39 Quote from: josh on September 17, 2018, 05:30:06 pmbut if you create a bundle and try the bundle then it crashes. do you have a backtrace of the crash? (macOS would offer one by itself) As well as crash <> 100% CPU use. So we might be facing two different problems. ---------------------------------------------------------------------- Josh · 2018-09-17 20:37 Hi Attached MAC Error Dump Log ---------------------------------------------------------------------- skalogryz · 2018-09-17 20:56 Try to get the latest trunk and see if it fixes the issue. (there were some changes related to focus notification. The log indicates "becomeFirstResponder" in the stack. So there's a slight chance of the issue to be fixed by now). seems to be a common problem. Cocoa doesn't like a modality to be invoked either during paint or during activation of another window. Does it work in Carbon? ---------------------------------------------------------------------- Josh · 2018-09-17 21:57 Hi Just updated to laz 2.1.0 svn 59053, fpc 3.3.1 deleted bundle, rebuilt app- recreated bundle, same problem. works fine in carbon. ---------------------------------------------------------------------- Josh · 2018-09-17 22:47 Hi The problem is when you place anything that creates a modal in the form onactivate event on Cocoa; but only when its run in the bundle. The executable works on its own. I will try a work around along the lines of Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i factivated:boolean=false;form.oncreate;{$ifdef darwin} // disable form_activate eventform.activate:=nil;{$endif} form.OnShow;{$ifdef darwin}  // cannot call modal stuff from on activate but can from form show;form.show; //force form to displayform.setfocus; // force form focusif factivated=false thenbegin  factivated:=true;  form.OnActivate;end;{$endif}.... rest of code for form.show  I will test now with my orginal project to see if this idea works. Unless there is another event I can use in place of the OnActivate event that is called after the form is created and active; but before the form OnShow Event is fired. ---------------------------------------------------------------------- skalogryz · 2018-09-17 23:00 it works fine in 10.6 hmm ---------------------------------------------------------------------- skalogryz · 2018-09-17 23:43 try this sample! remember to launch it from bundle. (if the one in archive won't work, simply recreate the bundle) ---------------------------------------------------------------------- skalogryz · 2018-09-18 02:26 after altermanual test, please update to the latest trunk and try again. ---------------------------------------------------------------------- Josh · 2018-09-18 10:09 Just updated laz to 59063 It indeed solves the problem, so I can use showmessages etc in the activate form event I will test with other projects that use this event. Not sure if its this change that has bought on an issue with IDE Press CMD F or Search FInd, the dialog is not on top and is beneath other windows so is not in view, if you then press CMD F again, you then get an error and Laz will generaly crash. Edit: Run/Clean Up and Build is also not shown on top; but calling it the second time does not create a crash you just have to find where it is. Edit: And others too nb I could not test your attachment as it did not contain and .pas file, just lpi,lpr and the bundle ---------------------------------------------------------------------- skalogryz · 2018-09-18 12:25 Quote from: josh on September 18, 2018, 12:09:25 pmnb I could not test your attachment as it did not contain and .pas file, just lpi,lpr and the bundle .lpr is lazarus project and .lpi is pretty much .pas file. Quote from: josh on September 18, 2018, 12:09:25 pmNot sure if its this change that has bought on an issue with IDE Press CMD F or Search FInd, the dialog is not on top and is beneath other windows so is not in view, if you then press CMD F again, you then get an error and Laz will generaly crash.it might be. Try to revert the change in CocoaInt.pas file and see if it restores the proper functionality. ---------------------------------------------------------------------- Josh · 2018-09-18 12:46 Hi svn 59063 is causing many problems and strange random crashes, so I will have to go back to 59053. Yes you application does finally open, after numerous attempts and crashes ( laz crashing). svn 59063 When I re-create the bundle, It crahses and OS error dumo has this. I can run the executable direct. QuoteApplication Specific Information: *** Terminating app due to uncaught exception 'NSGenericException', reason: '-[NSAlert runModal] may not be invoked inside of transaction begin/commit pair, or inside of transaction commit (usually this means it was invoked inside of a view's -drawRect: method.)' abort() called terminating with uncaught exception of type NSException ---------------------------------------------------------------------- skalogryz · 2018-09-18 12:56 try to update to r59059 it should be stable for you. ---------------------------------------------------------------------- Josh · 2018-09-18 15:27 Hi Just Removed My Installation and created a completely New LAZ, upated to 59063 Problem of menu options appeearing behind other still exists, Project Options appears behind sorce editor. If I remove your app bundle so I can create a new one, I get confirmation the its created the bundle, clicking ok causes Laz to Exit without error. Launching the created app bundle, causes an error. launching the executable works. ---------------------------------------------------------------------- skalogryz · 2018-09-18 15:39 Quote from: josh on September 18, 2018, 05:27:02 pmHi Just Removed My Installation and created a completely New LAZ, upated to 59063 no need to be that radical! seriously ---------------------------------------------------------------------- Josh · 2018-09-18 19:29 Laz rev 59063 and 59064 on Cocoa OPM not working, crashing out when building. Manually adding in package, crashes out when building IDE. Most modal dialog of ide are not brought to the front, which causing problems. IDE Not useable. I have used Onyx to clear all caches etc. Checking every few hrs for any laz updates ---------------------------------------------------------------------- Josh · 2018-09-19 13:03 Update Now running svn 59081. this has same issues as starting svn 59053, as though behaviour has been reverted. Any Modal Stuff, showmessage dialog stuff placed in OnActivate event causes app to not show/crash. Only work around that is working at present is not to use the OnActivate and Use the OnSHow Event. Also svn59081 still has the issues of menu options etc not being shown in front; so ar hidden underneath the source or form ---------------------------------------------------------------------- skalogryz · 2018-09-19 13:43 Quote from: josh on September 19, 2018, 03:03:15 pmNow running svn 59081. this has same issues as starting svn 59053, as though behaviour has been reverted. Any Modal Stuff, showmessage dialog stuff placed in OnActivate event causes app to not show/crash. Only work around that is working at present is not to use the OnActivate and Use the OnSHow Event. That's expected. The latest revision simply reverts the changes done and restores the original functionality. Quote from: josh on September 19, 2018, 03:03:15 pmAlso svn59081 still has the issues of menu options etc not being shown in front; so ar hidden underneath the source or form This it not expected. The behavior must have been caused by some other changes (maybe not in Cocooa) ---------------------------------------------------------------------- skalogryz · 2018-09-20 04:16 Quote from: josh on September 19, 2018, 03:03:15 pmAny Modal Stuff, showmessage dialog stuff placed in OnActivate event causes app to not show/crash. the bitter pill is in place! check out yourself! ---------------------------------------------------------------------- Josh · 2018-09-20 18:10 rev 59094 ShowMessage Dialog in onactivate still causing exec in bundle to not display or crash. IDE menu still under other forms, ie run->clean and build  is not on top. Tools->Config Build Laz ide using Dark Theme, i am getting sporadic crashes of IDE ( spinning wheel, 99% cpu) when resizing ide windows; mainly on object inspector..  Turning off dark theme no such error. ---------------------------------------------------------------------- skalogryz · 2018-09-20 19:00 Quote from: josh on September 20, 2018, 08:10:14 pmrev 59094 ShowMessage Dialog in onactivate still causing exec in bundle to not display or crash. What's the error log? how does "Services" menu look like? Quote from: josh on September 20, 2018, 08:10:14 pmIDE menu still under other forms, ie run->clean and build  is not on top. Tools->Config Build Laz ide using Dark Theme, i am getting sporadic crashes of IDE ( spinning wheel, 99% cpu) when resizing ide windows; mainly on object inspector..  Turning off dark theme no such error. No need to mix issues. ---------------------------------------------------------------------- skalogryz · 2018-09-22 17:38 Quote from: josh on September 20, 2018, 08:10:14 pmShowMessage Dialog in onactivate still causing exec in bundle to not display or crash. please bug-report the issue. There's no an easy fix (I reverted the hack applied previously) Without the bug-report the issue could be left forgotten. I'm planning to stop cocoa development (for the next couple of months or more) starting the next week. ---------------------------------------------------------------------- VTwin · 2018-09-28 13:32 Quote from: skalogryz on September 22, 2018, 07:38:02 pmI'm planning to stop cocoa development (for the next couple of months or more) starting the next week.   Your contributions are greatly appreciated! I hope you will be back soon after the break. ---------------------------------------------------------------------- skalogryz · 2018-09-30 20:12 Quote from: VTwin on September 28, 2018, 03:32:13 pm Your contributions are greatly appreciated! I hope you will be back soon after the break. it's not actually a break. it's a second job ---------------------------------------------------------------------- MISV · 2018-09-30 20:19 You have been an app saver skalogryz (which is a big thing for me) - without you I think many would have been dead-in-water on Mac. Do you have any blog or similar where one can follow you? Actually that goes for all core Lazarus members (and larger framework contributors) - you should have a profiles section where all this information is listed