LMMS / lmms

Cross-platform music production software
https://lmms.io
GNU General Public License v2.0
7.96k stars 994 forks source link

Program not closing properly #7385

Open SalutanisOrkonus opened 1 month ago

SalutanisOrkonus commented 1 month ago

System Information

Windows 10

LMMS Version(s)

1.3.0-alpha.1.658+g1420a1f7e

Most Recent Working Version

No response

Bug Summary

at least most of the time I close the program, I have to go into task manager and manually close it there. this is mainly a problem because the plugins also don't unload. my computer is unhappy

Expected Behaviour

program closes when it closes

Steps To Reproduce

Open program, open a project, close program, look in task manager.

Logs

No response

Screenshots / Minimum Reproducible Project

No response

Please search the issue tracker for existing bug reports before submitting your own.

michaelgregorius commented 1 month ago

This sounds like a duplicate of #6246.

musikBear commented 1 month ago

This sounds like a duplicate of #6246.

How come no one can reproduce? I could not i 6246, and i have just checked this once more: I just cant reproduce -Can You?!

michaelgregorius commented 1 month ago

This sounds like a duplicate of #6246.

How come no one can reproduce? I could not i 6246, and i have just checked this once more: I just cant reproduce -Can You?!

I cannot reproduce it as I am not running LMMS on Windows.

@SalutanisOrkonus, what driver have you set in the audio settings of LMMS? Can you please check if the problem persists if you change the driver as proposed by @PhysSong in https://github.com/LMMS/lmms/issues/6246#issuecomment-1015986480?

SalutanisOrkonus commented 1 month ago

My audio interface is set to SDL (Simple DirectMedia Layer), and I don't know if I'm misunderstanding the options here but none of these other options look like I wanna be switching to them image

michaelgregorius commented 1 month ago

For "JACK" you will need to have a JACK server running which might be a bit much just for testing. The "Dummy" device will provide no actual output. However, "PortAudio" might work. Can you give it a try?

You should always be able to reset it to "SDL". Otherwise that would be a bug on its own. :sweat_smile:

SalutanisOrkonus commented 1 month ago

most portaudio settings give no sound and the one that does is all choppy and slow

michaelgregorius commented 1 month ago

Ok, that's unfortunate. Does the application correctly close with these settings though?

SalutanisOrkonus commented 1 month ago

oh I somehow completely forgot to check that. Just did, the problem is rather inconsistent so this is by no means definitive, but I did not have it happen while using portaudio after some attempts

michaelgregorius commented 1 month ago

Also linking https://github.com/LMMS/lmms/issues/4668 as related here. It has an open pull request with merge issues and code where the author already knows that it's not ideal. See the comments with "future_hint" in pull request https://github.com/LMMS/lmms/pull/6070.

musikBear commented 1 month ago

My audio interface is set to SDL (Simple DirectMedia Layer)

And that is the correct and best audio-backend for all windows installations! Only ASIO4All is 'better', but it has a very bad crash history, where BCOD and several stern warnings are casted. Every windows user should use SDL! How long ago is that you made a proper cold boot of your PC?

SalutanisOrkonus commented 1 month ago

I turn my computer completely off every night and turn it back on in the morning. I even have window's fast startup off.

michaelgregorius commented 1 month ago

@SalutanisOrkonus, I know it's an extra step and even more software on the machine but you could also try to install JACK and select the corresponding driver in LMMS: https://jackaudio.org/downloads/

It's a low latency and real-time sound server that's intended for professional audio. I have never tested it on Windows though. But perhaps it's working better for you.

From what I read SDL can have very high latency on Windows so it might not really be the best audio back end on Windows, especially when recording audio.

bratpeki commented 1 month ago

Can'r replicate, closes fine on Linux, both with PulseAudio and SDL.

musikBear commented 1 month ago

Can'r replicate, closes fine on Linux, both with PulseAudio and SDL.

The OP is on a windows 10 pc. So am i and i cant reproduce, but i do not have the same LMMS build. I will try and see if i can find someone that has OPs build, but that is a longshot..

@SalutanisOrkonus said

oh I somehow completely forgot to check that. Just did, the problem is rather inconsistent so this is by no means definitive

what about other projects? If you load projects\demos\Greippi - Krem Kaakkuja (SecondFlight Remix).mmpz save once, and then shut down, what happens then?

firewall1110 commented 1 month ago

How I remember, problem is (semi)bug in SDL2: if audio recording callback returns too late , than SDL2 audio recording thread hung (some kind of dead lock) , this thread may not use too much CPU, but it prevents SDL driver to shut down: LMMS hung while closing. This event depends on: (1) Why recording callback returns too late? (2) What is too late? (And I hope, that this bug fixed on new SDL2 versions - but do not know ...) Answer on (1) Audio recording callback is activated by LMMS initialization and this time CPU is too busy (but it depends on OS type/settings, caching, CPU cores, ... ) [My PR simply not activate this CB on LMMS initialization but provides way how to turn it on/off when needed] I have no answer on (2) but it may be depends on SDL2 back-end, audio card, SDL2 version, ... So why is not so easy to reproduce this bug ...

michaelgregorius commented 1 month ago

@firewall1110, does any complex processing happen during the recording callback? Because to me it seems that this must be the case if the recording callback can return too late.

Perhaps my mental model is wrong but here's how I imagine it should work.

I assume that the driver works at a certain buffer size and that for a given period it will provide you input buffers that can be read and processed by the application and also output buffers that must be filled by the application. If that is the case then the course of actions should be something like the following:

  1. Read all input buffers that belong to the driver and copy their content into internal buffers.
  2. Tell the driver that the input buffers have been processed. If that is necessary at all. I guess we just have to finish the callback method.
  3. Execute the audio graph which can potentially use the copied input buffers, turn MIDI events into audio, etc.
  4. Write the resulting audio into the output buffers.

Because all we do is to simply copy the input buffers in step 1 there should be next to no chance that the callback for the input buffers is late.

firewall1110 commented 1 month ago

I do not remember, but some how audio recording (may be not only) call back simply is not scheduled || blocked until LMMS initialization process finished , ...

(I simply add some fprintf(stderr, ...) in audio recording callback and always text was after all initialization log)

From my point of view it is bad practice to do audio recording callback, then not needed - so I was not analyzing this deeper. If we (for example) add recording for Jack, then anyway we should (1) prepare "audio input clients" (don,t remember - but Your understand) for tracks to record (may be multiple) (2) connect to sources (3) only then audio callbacks will be activated So on default audio recording callback should not be running on LMMS start (may be only after some project with "armed" tracks is loaded (but if audio device changed ? what sources should be connected?), ) On my Linux/Debian SDL2 has multiple recording sources, and sources changes after I connect (remove) my recording device. So: (1) choose input device, than (2) activate audio recording callback , then (3) record some audio (may be multiple) then (4) de-activate recording callback and only then (this should be done automatically, if user not do this himself) (5) close LMMS with shut down audio driver.

P.S. Just compiled master: SDL works fine with 128 buffer - I can not reproduce this bug om my computer anymore

Lv2 plugin SUMMARY: 397 of 512 loaded in 2611 msecs. For details about not loaded plugins, please set environment variable "LMMS_LV2_DEBUG" to nonempty. Blocked Lv2 Plugins: 24 of 512 If you want to enable them (dangerous!), please set environment variable "LMMS_ENABLE_BLOCKED_PLUGINS" to nonempty. AudioSdl::startProcessing()AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded fluidsynth: warning: Preset 'Melo Tom 2': Some invalid generators were discarded AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAqt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 1280, resource id: 22890094, major code: 40 (TranslateCoords), minor code: 0

So now (1) [AudioSdl::startProcessing()] audio recording callback activated at the end of LMMS initialization process (but before project loading) (2) [AAAA...] nothing "block" audio recording callback ... No problem to fix?

firewall1110 commented 1 month ago

I tried LMMS (32-bit and 64-bit) on Windows 10 (64-bit) : SDL works fine.

P.S. (off topic) (1) Portaudio not work (how I remember, I was found good portaudio.dll for my student, but now we are using LINUX (and study time finished too)) (2) In pattern editor .ds files often produce terrible sound (when send not to master), and it is not effect plugin problem - sends from instrument track are ok.