Need to be able to cancel in-progress timers

RESOLVED FIXED in mozilla0.9.1


Core Graveyard
Widget: Mac
17 years ago
8 years ago


(Reporter: Simon Fraser, Assigned: Simon Fraser)


Mac System 8.5

Firefox Tracking Flags

(Not tracked)



(1 attachment)



17 years ago
The mac timer code currently bails on cancelling a timer that is currently being 
fired. However, because it's possible to have repeating timers, this makes it 
impossible to cancel timers from their callbacks. Also, the other platforms 
implement this.

Comment 1

17 years ago
Created attachment 29898 [details] [diff] [review]
Mac timers fix

Comment 2

17 years ago
dcone: please test the attached patch, and let me know if it works. I can't test, 
because no other places in the code seem to attempt to cancel repeating timers 
from the callback.

Comment 3

17 years ago
looks like this one may be getting in by moz0.9
Priority: -- → P3
Target Milestone: --- → mozilla0.9

Comment 4

17 years ago
I tried the timer.. and the code gets only called once, so this does not work 
If you want to debug.. the timer is in 

mozilla/content/base/src/nsDocumentViewer.  There is a timer in there.
Go to the Notify method, this is the entry point for the timer and gets called 
only once.  If you print example 0, there will be two pages.. the timer gets 
called for the first page, but never the second page.. 
the correct behavior would be that the notify should get called once for each of 
two pages and then stop.

Comment 5

17 years ago
dcone: Print doesn't work for me in either viewer or Mozilla, so I can't debug 
this. Can you please try to debug the Mac timer changes here.

You should hit the assertion at:
NS_ASSERTION(aTimer->GetType() == NS_TYPE_ONE_SHOT, "Cancelling repeating 

when you try to cancel the repeating timer (the assetion is just for debugging, 
it should be removed from the patch). This should set aTimer->mCanceledInCallback 
to true, which causes the timer to get cancelled when its callback is done.

Comment 6

17 years ago
Additional note: I saw a repeating timer get cancelled (from, I think, image 
code) and stuff seemed to work fine. Should I be able to debug the print stuff 
saari has been pulling his hair out over something like this in the art decoder. 
it seems repeating timers can be cancelled just dandy on mac, but you can't 
restart them on win32. cc'ing him.

Comment 8

17 years ago
Printing uses the one shot timer now, a page starts for each timer, so debuggin 
the repeating timers there will not work. The printing should have used one shot 
timers since repeating timers could have been notified multiple times for a 
page.  I am not sure who uses multiple timers now.. but this issue should still 
be fixed and tested for consistency across platform, it can cause problems as I 
found out.
Also.. to restart the windows timers.. you have to create a new one.. not just 
restart. On the Mac.. you can just restart them. I did go thru this problem 

Comment 9

17 years ago
Target Milestone: mozilla0.9 → mozilla0.9.1
looks good, r=pink

Comment 11

17 years ago
scc/waterson: can I have an sr please?

Comment 12

17 years ago

Comment 13

17 years ago
Thanks man. Just 1 second too late for my checkin comment!.
Checked in.
Last Resolved: 17 years ago
Resolution: --- → FIXED


13 years ago
Component: XP Miscellany → Widget: Mac


8 years ago
Component: Widget: Mac → Widget: Mac
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.