2019-03-22 07:05 UTC

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002227NetSurfCore-specificpublic2016-02-16 13:51
ReporterChris Young 
Assigned ToChris Young 
SeverityminorReproducibilityalways 
StatusclosedResolutionfixed 
PlatformAmigaOSAmigaOSOS Version4.1
Product Version3.3 
Target Version3.4Fixed in Version3.4 
Summary0002227: nsgif_animate runs when gif not displayed
Descriptionnsgif_animate starts running when an animated gif is displayed, but does not stop running when it is not displayed (or even when it is no longer in any browser_window). It only stops running when the object is destroyed.
Steps To ReproduceFind a page with an animated GIF. Browse off of that page and keep browsing until it is destroyed. Some extra logging in nsgif_animate will be required to see when it is running/stops running.
TagsNo tags attached.
Fixed in CI build #3390
Reported in CI build #2377
URL of problem page
Attached Files
  • patch file icon 1113ce117d5b860220bd979bd02dd067b8a9415e.patch (2,864 bytes) 2015-10-28 11:57 -
    From 1113ce117d5b860220bd979bd02dd067b8a9415e Mon Sep 17 00:00:00 2001
    From: Chris Young <chris@unsatisfactorysoftware.co.uk>
    Date: Fri, 12 Dec 2014 16:11:20 +0000
    Subject: Start and stop GIF animation on first/last user.
    
    ---
    diff --git a/content/content.c b/content/content.c
    index a27647b..1a249e7 100644
    --- a/content/content.c
    +++ b/content/content.c
    @@ -605,6 +605,9 @@ bool content_add_user(struct content *c,
     	user->next = c->user_list->next;
     	c->user_list->next = user;
     
    +	if (c->handler->add_user != NULL)
    +		c->handler->add_user(c);
    +
     	return true;
     }
     
    @@ -636,6 +639,10 @@ void content_remove_user(struct content *c,
     		assert(0);
     		return;
     	}
    +
    +	if (c->handler->remove_user != NULL)
    +		c->handler->remove_user(c);
    +
     	next = user->next;
     	user->next = next->next;
     	free(next);
    diff --git a/content/content_protected.h b/content/content_protected.h
    index 7311da6..e5ff1ca 100644
    --- a/content/content_protected.h
    +++ b/content/content_protected.h
    @@ -82,6 +82,8 @@ struct content_handler {
     	bool (*matches_quirks)(const struct content *c, bool quirks);
     	const char *(*get_encoding)(const struct content *c, enum content_encoding_type op);
     	content_type (*type)(void);
    +	void (*add_user)(struct content *c);
    +	void (*remove_user)(struct content *c);
     
             /** handler dependant content sensitive internal data interface. */
     	void * (*get_internal)(const struct content *c, void *context);
    diff --git a/image/gif.c b/image/gif.c
    index c2f0ae4..4455ff2 100644
    --- a/image/gif.c
    +++ b/image/gif.c
    @@ -398,6 +398,32 @@ static nserror nsgif_clone(const struct content *old, struct content **newc)
     	return NSERROR_OK;
     }
     
    +static void nsgif_add_user(struct content *c)
    +{
    +	nsgif_content *gif = (nsgif_content *) c;
    +
    +	/* Ensure this content has already been converted.
    +	 * If it hasn't, the animation will start at the conversion phase instead. */
    +	if(gif->gif == NULL) return;
    +
    +	if(content_count_users(c) == 1) {
    +		/* First user, and content already converted, so start the animation. */
    +		if (gif->gif->frame_count_partial > 1) {
    +			guit->browser->schedule(gif->gif->frames[0].frame_delay * 10,
    +						nsgif_animate,
    +						c);
    +		}
    +	}
    +}
    +
    +static void nsgif_remove_user(struct content *c)
    +{
    +	if(content_count_users(c) == 1) {
    +		/* Last user is about to be removed from this content, so stop the animation. */
    +		guit->browser->schedule(-1, nsgif_animate, c);
    +	}
    +}
    +
     static void *nsgif_get_internal(const struct content *c, void *context)
     {
     	nsgif_content *gif = (nsgif_content *) c;
    @@ -421,6 +447,8 @@ static const content_handler nsgif_content_handler = {
     	.destroy = nsgif_destroy,
     	.redraw = nsgif_redraw,
     	.clone = nsgif_clone,
    +	.add_user = nsgif_add_user,
    +	.remove_user = nsgif_remove_user,
     	.get_internal = nsgif_get_internal,
     	.type = nsgif_content_type,
     	.no_share = false,
    --
    cgit v0.9.0.3-65-g4555
    
    patch file icon 1113ce117d5b860220bd979bd02dd067b8a9415e.patch (2,864 bytes) 2015-10-28 11:57 +

-Relationships
related to 0002228acknowledged Possible race condition with scheduler 
+Relationships

-Notes
Chris Young

~0000540

Chris Young (developer)

I think nsgif_animate should only continue to run if the GIF in question is being displayed, or at the very least exists in a currently displayed browser_window.
At the moment there is some overhead from calling this function several times a second for each animated gif when it isn't relevant.
Chris Young

~0000556

Chris Young (developer)

I've pushed a potential fix to chris/stop-gif-anim.
Functionally it works but will need checking/merging.
It also guards against the problem in related bug#2228
Chris Young

~0000981

Chris Young (developer)

Patch attached for just the GIF issue.
Vincent Sanders

~0001222

Vincent Sanders (administrator)

Confirmed fixed in 3.4 release
+Notes

-Issue History
Date Modified Username Field Change
2014-11-23 16:42 Chris Young New Issue
2014-11-23 16:43 Chris Young Note Added: 0000540
2014-12-01 14:17 Vincent Sanders Status new => confirmed
2014-12-09 15:21 Chris Young Relationship added related to 0002228
2014-12-12 17:14 Chris Young Note Added: 0000556
2015-10-28 11:57 Chris Young File Added: 1113ce117d5b860220bd979bd02dd067b8a9415e.patch
2015-10-28 11:57 Chris Young Assigned To => Chris Young
2015-10-28 11:57 Chris Young Status confirmed => assigned
2015-10-28 11:57 Chris Young Note Added: 0000981
2015-10-28 11:57 Chris Young Status assigned => confirmed
2015-11-07 22:03 Chris Young Category General => Core-specific
2015-11-07 22:03 Chris Young Target Version => 3.4
2015-11-07 22:03 Chris Young Description Updated View Revisions
2016-02-11 19:57 Chris Young Fixed in CI build # => 3390
2016-02-11 19:57 Chris Young Status confirmed => resolved
2016-02-11 19:57 Chris Young Fixed in Version => 3.4
2016-02-11 19:57 Chris Young Resolution open => fixed
2016-02-16 13:51 Vincent Sanders Note Added: 0001222
2016-02-16 13:51 Vincent Sanders Status resolved => closed
2016-02-16 13:51 Vincent Sanders Description Updated View Revisions
+Issue History