Lazarus

Programming => Graphics and Multimedia => Audio and Video => Topic started by: pcurtis on May 29, 2021, 12:06:42 am

Title: [CLOSED] I can't debug a program that uses PasLibVLC in the IDE.
Post by: pcurtis on May 29, 2021, 12:06:42 am
I can't use PasLibVlc in the IDE. When I run the exe  out of the IDE all is OK.
This goes for the demo apps or my own.

Is there a setting I am missing?

Both VLC and PasLibVlc are the latest versions.
Title: Re: PasLibVlc problem
Post by: pcurtis on May 31, 2021, 01:23:52 pm
So probably I will dump PasLibVlc if it doesn't work and is unsupported  :( :(
Title: Re: PasLibVlc problem
Post by: MarkMLl on May 31, 2021, 01:37:03 pm
Who says it's unsupported? Have you raised a bug in the appropriate place? Have you allowed that it's a holiday weekend in many countries (a Bank Holiday in the UK, Memorial Day Weekend in the USA and so on) so you can hardly expect attention within 24 hours? Are you able to describe coherently what the problem is? Have you looked back through the forum for other users' experiences?

MarkMLl
Title: Re: PasLibVlc problem
Post by: pcurtis on May 31, 2021, 02:23:09 pm
Yes.

The problem is it is unresponsive at design time. It's even commented here http://lazplanet.blogspot.com/2018/01/how-to-make-simple-video-player-in.html (http://lazplanet.blogspot.com/2018/01/how-to-make-simple-video-player-in.html)

There are no comments here on this site.

There is no usage information available (even basic), and the inability to debug in the IDE make it unusable.http://
Title: Re: PasLibVlc problem
Post by: MarkMLl on May 31, 2021, 02:52:47 pm
There are no comments here on this site.

Really? I get three pages of forum hits results.

MarkMLl
Title: Re: PasLibVlc problem
Post by: pcurtis on May 31, 2021, 03:00:19 pm
What "text" did you search for?
Title: Re: PasLibVlc problem
Post by: Zvoni on May 31, 2021, 03:13:36 pm
I agree with OP
I also took a look at PasLibVlc some months ago, and the shipped demo/example just crashed in the IDE
I didn't raise anything, since it wasn't that important to me at that time
Title: Re: PasLibVlc problem
Post by: pcurtis on May 31, 2021, 03:23:34 pm
@zvoni - Phew, at least now I know I'm not crazy  ;D
BTW Do you remember what OS you used?
Title: Re: PasLibVlc problem
Post by: Zvoni on May 31, 2021, 03:35:28 pm
@zvoni - Phew, at least now I know I'm not crazy  ;D
BTW Do you remember what OS you used?

Manjaro Cinnamon incl. current VLC at that time
Title: Re: PasLibVlc problem
Post by: pcurtis on May 31, 2021, 03:55:45 pm
So it's not a Windows thing.
Title: Re: PasLibVlc problem
Post by: MarkMLl on May 31, 2021, 05:07:24 pm
What "text" did you search for?

libvlc

MarkMLl
Title: Re: PasLibVlc problem
Post by: MarkMLl on May 31, 2021, 05:13:55 pm
So it's not a Windows thing.

With the caveat that I've not tried it and have no incentive to try it (I've quite simply got too many other things on my plate)...

Are you saying that a compiled program will run standalone, but not in the IDE? OP read more as though it didn't display anything at design time which of course is a completely different matter.

What happens if it's run in the IDE but without the debugger? What happens if fpdebug (?) is used rather than gdb? What happens (in the case of Linux) if it's run using gdbserver which is then driven by the IDE? Ditto with gdbserver+app running as root?

These are all basic questions, which should have been investigated before a "this library is crap" verdict.

MarkMLl
Title: Re: PasLibVlc problem
Post by: pcurtis on May 31, 2021, 05:18:18 pm
Quote
Are you saying that a compiled program will run standalone, but not in the IDE?

Exactly, as mentioned in the opening post

Quote
I can't use PasLibVlc in the IDE. When I run the exe  out of the IDE all is OK.

 with or without debugger.
Title: Re: PasLibVlc problem
Post by: MarkMLl on May 31, 2021, 06:06:21 pm
Quote
Are you saying that a compiled program will run standalone, but not in the IDE?

Exactly, as mentioned in the opening post

Quote
I can't use PasLibVlc in the IDE. When I run the exe  out of the IDE all is OK.

 with or without debugger.

There's no "exactly" about it. Your OP read as though you were complaining that it didn't work at design time, i.e. like a database component can't be used live inside the debugger.

I suggesting waiting until tomorrow when Martin might be in circulation, but you'd do yourself a favour by changing your subject line to say explicitly that you can't run or debug a program using libvlc in the IDE.

MarkMLl
Title: Re: PasLibVlc problem
Post by: Martin_fr on May 31, 2021, 07:50:55 pm
The problem is it is unresponsive at design time.

I am using PasLibVlc on windows. No issues at design time...

At runtime, yes ...
A small (but not dramatic) slowdown at runtime, and sometimes freezes when changing videos. Not yet sure why, probably upsets some timing in the lib.

I found using a newer gdb may help. https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/Alternative%20GDB/
The "modified 9.2" seems to do well. (tested on 64bits / there is one for 32bits too, but not tested with PasLivVlc)
Note: You can probably use that gdb with an older IDE, but you must keep all environment, command line args, and exename+path in plain English ASCII. I.e if you hand the debugger any accented or other chars, that may not work.

Or try FpDebug, works often - but not always.
Title: Re: I can't run or debug a program that uses PasLibVLC in the IDE.
Post by: Martin_fr on May 31, 2021, 08:27:46 pm
Also, if you use gdb, you can try the option "DisableLoadSymbolsForLibraries" in the global debugger options (see the property grid on the debugger opt page)
Title: Re: I can't run or debug a program that uses PasLibVLC in the IDE.
Post by: pcurtis on May 31, 2021, 08:45:36 pm
Ok, I've tried those suggestions and still no joy. I am at a loss, what to do next?
Title: Re: I can't run or debug a program that uses PasLibVLC in the IDE.
Post by: Martin_fr on May 31, 2021, 09:14:24 pm
Ok, one step back...

1) You are indeed on Windows?
64 bit?
Intel (or AMD)  / as opposed to ARM.

Your Lazaruse is 2.0.10 or .12 ?
According to your sig Fpc 3.2.0
I am testing 3.2.2 / and have previously had 3.0.4 / never done 3.2.0

2) Lets confirm, this is about running under the debugger?
designing has no issues? (afaik PasLibVlc does not load vlc at designtime)

"Run without debugger" should also be fine?

3) More details when the problems happen?
Is the error are (dramatic) slowdown? a freeze? a crash? a ....?

Does your app - when started - immediately start playing a video?
When does the error happen? (startup, when you play/stop/seek a video?)
Does the main form show?

When using gdb, open the "Debug output" (not "console output") (either view > debug windows / or view > ide internals).
Not yet important what the output is (unless is say big and fat "error").
But how much output is made while the problem happens?
(Just to see how much gdb has to deal with)

4) Does the issue happen with the examples in PasLibVlc? (DemoPasLibVlc)
Try different videos mp4 vs avi. (more important diff codec)



Bit of background...

From what I can tell a PasLibVlc project start quite a few threads.
Depending on how often one of them terminates and/or is newly started, this can cause extra event in the debugger. That can cost a few millisecs (if loading symbols is off). Not a dramatic amount of time, but enough to change timing as perceived by vlc.
If vlc's thread sync is vulnerable to timing (pure guessing... hypothetical) then that can cause freezing.



Check in the breakpoint window, that you do not have unwanted breakpoints.
Title: Re: I can't run or debug a program that uses PasLibVLC in the IDE.
Post by: Martin_fr on May 31, 2021, 09:41:53 pm
Ok, so I tried with 2.0.12. And at least my own app freezes 99% of the time that I change a video. (while on trunk it is mostly fine / not perfect, but workable)

I haven't evaluated all of the diffs....
- Could by a change in LCL and Lazarus. But at least the IDE gdb debugger code, that is unlikely
- different gdb versions 7.3.5 for 2.0.12  / and "9.2 mod" for trunk
- different  fpdebug
- different fpc version (if vlc is loaded as lib, then even if that lib starts/stops threads that goes through fpc code)

I am not going to test all the combinations myself.
Title: Re: I can't run or debug a program that uses PasLibVLC in the IDE.
Post by: pcurtis on May 31, 2021, 10:04:17 pm
So to answer your questions -

1. Windows 10, 64 bit AMD. Laz 2.0.10, Fpc 3.2.0

2. I can design without issues. The problem occurs only when I run in the IDE.
The problem occurs with the debugger on or off (Project options >  Debugging > Generate info for debugger)

3. The app starts normally but when I try to play a movie it becomes unresponsive. The movie never plays.

4. The issue occurs also with the demo programs.

Title: Re: I can't run or debug a program that uses PasLibVLC in the IDE.
Post by: Martin_fr on May 31, 2021, 10:50:08 pm
Strange.

To complete my setup
vlc 3.0.12  just while I type this  upgraded to 3.0.14

I can play and seek  without issues.

When I try to start another video, I have maybe a 30% chance of it freezing. (maybe my code misses something...)
When I stop the current video first and wait a bit, before starting the next, its works.

That sounds much better than what you get.

It could either be the different version (Laz/Fpc/fpdebug) that I use.
Or it could be how I call the vlc lib. (though then I should have problems with the demo, and that worked for me)

It could also be the video streams in question. It could be a specific decoder...


The only thing I can think of you can try is to upgrade. I can't tell if it will help.



Title: Re: I can't run or debug a program that uses PasLibVLC in the IDE.
Post by: MarkMLl on May 31, 2021, 10:59:30 pm
When I try to start another video, I have maybe a 30% chance of it freezing. (maybe my code misses something...)
When I stop the current video first and wait a bit, before starting the next, its works.

This is not something I claim experience of, and my earlier involvement was as much as anything intended as a placeholder until you (Martin) got involved lest the OP got disgruntled and wandered off.

/BUT/... do we have a situation here where the library is using a socket to communicate with a backend, and the socket takes a bit of time to sort itself out between sessions? After all, the "L" in VLC is "LAN"...

MarkMLl
Title: Re: I can't run or debug a program that uses PasLibVLC in the IDE.
Post by: MarkMLl on May 31, 2021, 11:09:49 pm
The problem occurs with the debugger on or off (Project options >  Debugging > Generate info for debugger)

Irrelevant. What I asked earlier was whether it ran from inside the IDE without using the debugger, i.e. Run -> Run without Debugging.

Not having the debugging symbols simply means that the debugger can't do much useful, not that the debugger isn't between the OS and the program.

MarkML
Title: Re: I can't run or debug a program that uses PasLibVLC in the IDE.
Post by: Martin_fr on May 31, 2021, 11:55:36 pm
The problem occurs with the debugger on or off (Project options >  Debugging > Generate info for debugger)

Irrelevant. What I asked earlier was whether it ran from inside the IDE without using the debugger, i.e. Run -> Run without Debugging.

Not having the debugging symbols simply means that the debugger can't do much useful, not that the debugger isn't between the OS and the program.

Right, well spotted. Debug info off, is still a debugger running.  Windows still will interrupt the exe to tell the debugger about various events: exceptions, dll load/unload, threads/processes start/stop, ...

I don't suspect that any of the code is actively looking for the debugger to be present.
But I do suspect that some code may be sensitive to timing. And the debugger does change timing.
It might be a timeout on the socket. It may be thread communication. It may be something else.
Title: Re: I can't run or debug a program that uses PasLibVLC in the IDE.
Post by: pcurtis on June 01, 2021, 05:12:05 am
OK, the code runs from inside the IDE without using the debugger.
Title: Re: I can't debug a program that uses PasLibVLC in the IDE.
Post by: MarkMLl on June 01, 2021, 10:29:31 am
Are you up to trying to run the program outside the IDE under the debugger? Martin might need to fill you in on the details since he'll know where GDB is etc.

MarkMLl
Title: Re: I can't run or debug a program that uses PasLibVLC in the IDE.
Post by: MarkMLl on June 01, 2021, 10:39:01 am
Right, well spotted. Debug info off, is still a debugger running.  Windows still will interrupt the exe to tell the debugger about various events: exceptions, dll load/unload, threads/processes start/stop, ...

And in the general case the debugger and debugee might not have the same security credentials. I've got code here which can (only) be debugged using gdbserver running as root.

MarkMLl
Title: Re: I can't debug a program that uses PasLibVLC in the IDE.
Post by: pcurtis on June 01, 2021, 10:40:23 am
Why not.

GDB Is here c:\lazarus\mingw\x86_64-win64\bin\

What do I do?
Title: Re: I can't debug a program that uses PasLibVLC in the IDE.
Post by: MarkMLl on June 01, 2021, 11:06:28 am
Bear in mind that I'm not running Windows, so this is general guidance only using a program to hand here. Something like

gdb something
run

I've just checked that with program using the LCL etc., and also with he main VLC binary without obvious problems although I didn't go looking for a file to play. If you need to give the debuggee parameters then it will be something like

gdb something
set args ...
run

I'm not saying it's the answer to everything, but I think it's a useful experiment. On Linux, I note various FIFOs and unix-domain sockets open, so I think there's a real possibility that this is a communications issue.

MarkMLl
Title: Re: I can't debug a program that uses PasLibVLC in the IDE.
Post by: Martin_fr on June 01, 2021, 11:07:02 am
Matching gdb and gdbserver for Win64 https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/Alternative%20GDB/GDB%208.2/

Some sort of howto: https://wiki.lazarus.freepascal.org/Remote_Debugging#Using_gdbserver


I am logged in with an admin account. But I am not sure it's a permission issue. Too random, at least for me.

However, if my guess (timing) is right, gdbserver might still help. Gdb reports to the IDE via pipes, that takes time (especially on Win). GdbServer talks to gdb over tcp. That may or may not make a difference.
Title: Re: I can't debug a program that uses PasLibVLC in the IDE.
Post by: MarkMLl on June 01, 2021, 11:15:20 am
However, if my guess (timing) is right, gdbserver might still help. Gdb reports to the IDE via pipes, that takes time (especially on Win). GdbServer talks to gdb over tcp. That may or may not make a difference.

It can also help with ownership issues. My notes say

Code: Pascal  [Select][+][-]
  1. (*  *   It may be debugged by being run like                                    *)
  2. (*                                                                              *)
  3. (*      # gdbserver :2345 ./Watchxxx-x86_64-linux-gtk2                          *)
  4. (*                                                                              *)
  5. (*      with the Lazarus IDE debugger backend set to remote/gdbserver.          *)
  6.  

Note that in this case any parameters should be on the command line https://bugs.freepascal.org/view.php?id=37581

Remember to switch the IDE back to ordinary gdb when done :-)

MarkMLl
Title: Re: I can't debug a program that uses PasLibVLC in the IDE.
Post by: pcurtis on June 01, 2021, 12:02:57 pm
So far I've tried MarkMLI's, and the program still doesn't play videos.
Title: Re: I can't debug a program that uses PasLibVLC in the IDE.
Post by: MarkMLl on June 01, 2021, 12:09:07 pm
So far I've tried MarkMLI's, and the program still doesn't play videos.

Which: both standalone debugger and gdbserver+IDE?

If so I think it points very much to a general libvlc problem rather than something to do with the IDE or underlying tools, and I think it's something you could usefully write up in the wiki.

MarkMLl


Title: Re: I can't debug a program that uses PasLibVLC in the IDE.
Post by: MarkMLl on June 03, 2021, 09:30:56 pm
I've just checked that with program using the LCL etc., and also with he main VLC binary without obvious problems although I didn't go looking for a file to play.

It would be interesting if, in fact, it's possible to run vlc under gdb but not a program using libvlc.

MarkMLl
Title: Re: I can't debug a program that uses PasLibVLC in the IDE.
Post by: pcurtis on June 04, 2021, 08:34:13 am
Guys, I have been side tracked the last couple of days,
but my result is this :
PasLibVlc (at least for me), is unusable. Without out of the box debugging (solving debugging issues for one component / application is not worth the effort) it is unusable, I also found that I can't seek in .ts files (not sure if this is a VLC or PasLibVLC problem). With these issues I decided to stick with MPV.

At least the issue has been half solved and I thank you for your assistance.

I will mark this post as CLOSED not SOLVED.
Title: Re: [CLOSED] I can't debug a program that uses PasLibVLC in the IDE.
Post by: MarkMLl on June 04, 2021, 09:07:15 am
OK, but for completeness (and the benefit of anybody who gets here via Google) this appears to be something to do with libvlc, and does not highlight a fault in the Lazarus IDE or the Pascal wrapper.

MarkMLl
Title: Re: [CLOSED] I can't debug a program that uses PasLibVLC in the IDE.
Post by: Fred vS on July 03, 2021, 10:18:35 pm
I can't use PasLibVlc in the IDE. When I run the exe  out of the IDE all is OK.
This goes for the demo apps or my own.

Is there a setting I am missing?

Both VLC and PasLibVlc are the latest versions.

I noted that it is extremely difficult to debug a application that deals with audio (or video + audio).
This because debugging "eats" latency with his analysis and so disturbs the flow of samples to sound card.

To resume, debug is OK to detect errors but the result in your loudspeakers may be bad.
Title: Re: [CLOSED] I can't debug a program that uses PasLibVLC in the IDE.
Post by: MarkMLl on July 03, 2021, 11:05:16 pm
I noted that it is extremely difficult to debug a application that deals with audio (or video + audio).
This because debugging "eats" latency with his analysis and so disturbs the flow of samples to sound card.

OTOH I think OP's said (although he's not explicitly confirmed) that he was able to run without breakpoints set, and even though Martin makes the point that the debugger silently intercepts various events I'd not have thought it would make that much difference on a modern CPU.

MarkMLl
TinyPortal © 2005-2018