NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 49 50 51 52 53 … 93 Next »
OSD Plugin Failure

 
  • 0 Vote(s) - 0 Average
OSD Plugin Failure
timsohn
Offline

Junior Member

Posts: 8
Threads: 3
Joined: Jun 2006
#1
2006-08-25, 08:42 PM (This post was last modified: 2006-09-05, 10:24 PM by timsohn.)
I've been working on a video plugin that forces itself to always be active. As a result its render method is called every second. The Render method basically takes some Controls and paints them onto a bitmap to overlay on top of the video. I've noticed an error, and I'm wondering if maybe there's something in GBPVR that can be fixed, or if it's an underlying windows error, in which case it's hopeless. Any thoughts would be great. I'm attaching the stack trace exception:

8/25/2006 9:57:00 AM.491 ERROR [1] Encounter unexpected exception in timerRefresh_TickTonguearameter is not valid.
8/25/2006 9:57:00 AM.491 ERROR [1] at System.Drawing.Graphics.GetHdc()
at System.Windows.Forms.Control.DrawToBitmap(Bitmap bitmap, Rectangle targetBounds)
at Plugin.TTPlugin.ApplicationLogic.render(Boolean& requiresMoreRendering) in C:\Documents and Settings\tsohn\TTPlugin\ApplicationLogic.cs:line 140
at TTPlugin.TTPlugin.render(Boolean& requiresMoreRendering) in C:\Documents and Settings\tsohn\TTPlugin\TTPlugin.cs:line 304
at TTPlugin.TTPluginProxy.render(Boolean& requiresMoreRendering) in C:\Documents and Settings\tsohn\socialTV\TTPlugin\TTPluginProxy.cs:line 95
at GBPVR.xb3e61f7448c39547.RefreshOSD()
at GBPVR.xbb1566157f5f8b1f.xb1cbc922a07ef39b(Object xdf2e3583f942db7b, EventArgs xc4f45905cb1fc7ba)
8/25/2006 9:57:01 AM.351 ERROR [1] Encounter unexpected exception in timerRefresh_Tick:A generic error occurred in GDI+.
8/25/2006 9:57:01 AM.351 ERROR [1] at System.Drawing.Bitmap.GetHbitmap(Color background)
at System.Drawing.Bitmap.GetHbitmap()
at NativeUtilities.MediaHelper.overlayBitmap(Image image)
at GBPVR.xb3e61f7448c39547.RefreshOSD()
at GBPVR.xbb1566157f5f8b1f.xb1cbc922a07ef39b(Object xdf2e3583f942db7b, EventArgs xc4f45905cb1fc7ba)
McBainUK
Offline

Posting Freak

Posts: 4,711
Threads: 429
Joined: Sep 2005
#2
2006-08-25, 09:06 PM
I've moved your post to the developers forum, seemed to be more suitable.

Quote:Parameter is not valid
Can you step through the code and see which parameter it is thats causing the error?

Is it generating the screen to be rendered each time, even if no changes? I found to many renders to quick would cause the Volume plugin to crash (also uses Ivideo interface).

ps. Sub may be able to help but he's away for a few days.
Wiki profile
My Projects
Programs Plugin [SIZE=2](retired)
| Volume OSD Plugin (retired) | Documentation Wiki (retired)
[/SIZE]
timsohn
Offline

Junior Member

Posts: 8
Threads: 3
Joined: Jun 2006
#3
2006-08-28, 09:34 PM
I modified my plugin to return a blank canvas everytime it is called. After letting GB-PVR run with my plugin active for about 4 hours, I get the following errors:

8/28/2006 12:28:54 PM.320 ERROR [1] Encounter unexpected exception in timerRefresh_Tick:A generic error occurred in GDI+.
8/28/2006 12:28:54 PM.335 ERROR [1] at System.Drawing.Bitmap.GetHbitmap(Color background)
at System.Drawing.Bitmap.GetHbitmap()
at NativeUtilities.MediaHelper.overlayBitmap(Image image)
at GBPVR.xb3e61f7448c39547.RefreshOSD()

Any ideas why this might be? I'm running GBPVR v0.97.9.
timsohn
Offline

Junior Member

Posts: 8
Threads: 3
Joined: Jun 2006
#4
2006-09-07, 08:31 PM
I think I may have a clue to why this problem occurs. In RefreshOSD() is there a Timer that is called to redraw the image? I'm thinking that maybe it gets called too quickly after a while and could end up trying to draw before the previous call finishes. Any insight would be great. Thanks
Snarky
Offline

Junior Member

Posts: 43
Threads: 7
Joined: Oct 2005
#5
2006-09-27, 07:56 PM
I also get the same error, even with a trivial video plugin. When the plugin has been active for about three hours (2 hours and 44 minutes at the last count), it starts throwing exceptions:

9/26/2006 2:33:36 PM.281 ERROR [1] Encounter unexpected exception in timerRefresh_Tick:A generic error occurred in GDI+.
9/26/2006 2:33:36 PM.281 ERROR [1] at System.Drawing.Bitmap.GetHbitmap(Color background)
at System.Drawing.Bitmap.GetHbitmap()
at NativeUtilities.MediaHelper.overlayBitmap(Image image)
at GBPVR.xb3e61f7448c39547.RefreshOSD()
at GBPVR.xbb1566157f5f8b1f.xb1cbc922a07ef39b(Object xdf2e3583f942db7b, EventArgs xc4f45905cb1fc7ba)
9/26/2006 2:33:37 PM.281 ERROR [1] Encounter unexpected exception in timerRefresh_Tick:A generic error occurred in GDI+.

The video continues to play, but if you press any key the application kicks you back to the main menu, with a message about an unexpected GDI+ error.

I'm running v0.97.9, but I doubt this is version related.

My code is very simple. It creates a Bitmap in Activate(), and returns the Bitmap (blank) every time render() is called. The only keypress that does anything is ESC, which sets a flag to deactivate the plugin. Otherwise, the plugin remains active all the time.

I have attached my source code, DLL and log file.
Snarky
Offline

Junior Member

Posts: 43
Threads: 7
Joined: Oct 2005
#6
2006-09-29, 01:06 AM
OK, I think I've discovered what the problem is, and it seems to be a GBPVR bug. The crash seems to have to do with the number of times render() has been called, total. A VideoPlugin can render itself fine about 9962 times. At that point, it crashes.

It doesn't matter if the plugin has been deactivated and activated at several points in between, and it doesn't matter if we have gone back and forth between different TV channels, between live TV and the main menu, or between different video recordings. Once the plugin has been rendered 9962 times, it crashes. Also, if the plugin deactivates itself once it has been rendered, say, 9950 times, and the standard GBPVR OSDs are brought up (the channel banners, mini-EPGs, etc.), this will also cause the same crash very quickly.

By restarting GBPVR, we get another 9962 calls to render() before it crashes again.

If a plugin is always active, it will render about once per second (if no keys are pressed). This means that it will crash after 2 hours and 46 minutes. I assume that without any outside plugins, GBPVR crashes when the OSDs have been visible for that amount of time, in total. (Actually, somewhat less, since they get rendered every time a key is pressed, also.)

Here's the code for my test plugin. The source code file is also attached, along with the DLL and my log file:

Code:
using System;
using System.Collections.Generic;
using System.Text;
using GBPVR.Public;
using System.Drawing;

namespace MinimalTest
{
    /// <summary>
    /// The purpose of this plugin is to cause render() to be called as many times as possible
    /// in a short period of time. This demonstrates that after about 9962 times, GBPVR will throw an exception
    /// and kick us back to the main menu. (This takes about 3 minutes on my computer.)
    ///
    /// We achieve this by generating lots of keypresses, each of which causes GBPVR to call the plugin's render()
    /// method.
    ///
    /// To run this plugin, place it in the gpbvr/plugins directory, and add "MinimalTest" to one of the
    /// <VideoPluginX></VideoPluginX> tags in gbpvr/config.xml, then launch GBPVR.
    /// </summary>
    public class MinimalTest : IMenuTask, IVideoPlugin
    {
        #region Constants

        private const string keysToSend = " ";        // Send a SPACE-bar keypress
        private const int keysBeforeBreak = 50;        // The number of keypresses to send in one "batch"

        //private const int renderLimit = 9950;                // Deactivate the plugin after rendering this many times
        private const int renderLimit = int.MaxValue;        // Deactivate the plugin after rendering this many times
        
        #endregion

        private Bitmap canvas;            // The Image the plugin is supposed to draw itself on
        private int renderCounter;        // How many times render has been called

        void renderAgain()
        {
            // By sending a keypress, the render method will be called again
            System.Windows.Forms.SendKeys.Send(keysToSend);
        }

        #region IMenuTask Members

        public void Activate()
        {
            canvas = new Bitmap(720, 480);    // Just a blank bitmap
        }

        public void Deactivate()
        {
            canvas.Dispose();
            canvas = null;
        }

        public System.Windows.Forms.Form GetConfigFormInstance(System.Xml.XmlDocument document)
        {
            return null;
        }

        public void OnClick(System.Drawing.Point location)
        {
            // do nothing
        }

        public void OnDoubleClick(System.Drawing.Point location)
        {
            // do nothing
        }

        public bool OnKeyDown(System.Windows.Forms.KeyEventArgs e)
        {
                return true;    // By returning true, GBPVR will call render() to "update the display".
        }

        public void OnMouseWheel(System.Windows.Forms.MouseEventArgs e)
        {
            // do nothing
        }

        public string getDescription()
        {
            return @"Minimal Test for video plugin crashing";
        }

        public string getName()
        {
            return @"MinimalTest";
        }

        public string getSkinSubdirectory()
        {
            return @"MinimalTest";
        }

        public System.Drawing.Image getTaskImage()
        {
            return null;
        }

        public bool needsRendering()
        {
            return false;
        }

        public System.Drawing.Image render(out bool requiresMoreRendering)
        {
            requiresMoreRendering = false;
            GBPVR.Public.Logger.Info("MinimalTest: Render " + renderCounter++);    // Write the number of times the plugin has rendered itself to the logfile
            return canvas;
        }

        #endregion

        #region IVideoPlugin Members

        public bool needsToBeHidden()
        {
            // After we've sent keysBeforeBreak keypresses, we give the application a break
            // (so that it won't use absolutely all resources and Windows will freeze on us).
            // At the next second, render() will be called again by GBPVR, and we send
            // another keysBeforeBreak keypresses.
            if (renderCounter % keysBeforeBreak != 0)
                renderAgain();
            return (renderCounter >= renderLimit);    // Run the plugin until we've rendered a certain number of times
        }

        public bool needsToBeShown()
        {
            return (renderCounter < renderLimit);    // Run the plugin until we've rendered a certain number of times
        }

        public void setVideoMode()
        {
            // do nothing
        }

        #endregion
    }
}

Although this particular plugin causes the crash by generating keypresses (in order to provoke the crash in about three minutes, instead of nearly three hours), a similar crash can be observed just by waiting.

(And yes, this is a problem for me, since the video plugin I'm working on is going to be active for long periods of time.)
Snarky
Offline

Junior Member

Posts: 43
Threads: 7
Joined: Oct 2005
#7
2006-10-03, 12:56 AM
I don't want to nag, but has anyone else verified this crash, or is able to suggest a workaround (or, possibly, promise a bugfix in the next version)?

If my theory of the problem is correct, a back-of-the-envelope calculation suggest that under normal/heavy use (without any external video plugins), GBPVR will crash after about running for about 3 months. Not a huge problem, perhaps, but it would be nice to get it fixed.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,807
Threads: 769
Joined: Nov 2003
#8
2006-10-03, 01:00 AM
I did read you comments above, and had a look at the code that is identified in the callstack. I havnt tried to reproduce it. Its a pretty simple bit of code, which is correct from what I can tell. I'm guessing its some bug in GDI+.
Snarky
Offline

Junior Member

Posts: 43
Threads: 7
Joined: Oct 2005
#9
2006-10-03, 11:09 PM
OK, I see. So there aren't any four-digit (decimal) counters that might be overflowing at 10,000 or anything like that? I don't suppose you could try running the code that precipitates the crash and stepping through the bit where it crashes? Well, thanks for taking a look at it.

It's a shame because it means it's impossible to have a video plugin that displays itself for extended periods of time, like a status icon or anything like that.
Snarky
Offline

Junior Member

Posts: 43
Threads: 7
Joined: Oct 2005
#10
2006-10-10, 06:59 PM
Some googling reveals that in GDI, you can only keep handles to 10,000 GDI objects per process, then it crashes. This bug seems to affect a pretty large number of applications. Now, supposedly this should not apply to GDI+, but maybe there's an analogous problem? Are the handles to the Bitmaps or Graphics objects passed by render() stored anywhere?
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (2): 1 2 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  PIP plugin for Kodi sgilani 2 3,081 2022-10-17, 12:44 AM
Last Post: sgilani
  New Systems Plugin kirschey 10 3,556 2020-11-14, 08:01 PM
Last Post: sub
  VIdeo playback from plugin mvallevand 5 3,639 2015-08-06, 10:43 PM
Last Post: sub
  Attention Sub: Open TV / Custom Data Grabber plugin Benoire 2 3,000 2014-11-14, 02:05 AM
Last Post: Benoire
  API docs to help with plugin development? McBainUK 3 2,870 2013-06-08, 06:14 PM
Last Post: sub
  Refreshing TV Guide Data (after System plugin EPG update) imilne 13 6,321 2013-03-24, 08:03 PM
Last Post: imilne
  sabnzbd plugin to show processed files Wakalaka 1 2,026 2013-03-12, 06:48 AM
Last Post: psycik
  Plugin problems with started from the command line mvallevand 11 5,241 2012-08-12, 07:56 PM
Last Post: sub
  Get NextPVR data directory from outside a plugin McBainUK 3 2,335 2012-02-11, 05:42 PM
Last Post: mvallevand
  Weather Plugin imilne 0 1,498 2012-01-15, 08:33 PM
Last Post: imilne

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode