Skip to content

Conversation

@jonahgraham
Copy link
Contributor

At the moment the code silently fails on calling timerExec if there are no handles left or it fails for other reasons.

Relates to #2806 where we can see that we are running out of handles, but the timerExec does not report a failure.

@jonahgraham
Copy link
Contributor Author

This is a draft for now because it needs consideration for other platforms and whether after 25 years there is a reason that this case was allowed to fail silently on Windows.

On macOS there is a pointless null check in the same place because an NPE would have already been raised. On GTK I need to investigate more because the functions are not documented as being able to fail.

macOS:

NSTimer timer = NSTimer.scheduledTimerWithTimeInterval(milliseconds / 1000.0, timerDelegate, OS.sel_timerProc_, userInfo, false);
NSRunLoop runLoop = NSRunLoop.currentRunLoop();
runLoop.addTimer(timer, OS.NSModalPanelRunLoopMode);
runLoop.addTimer(timer, OS.NSEventTrackingRunLoopMode);
timer.retain();
if (timer != null) {
nsTimers [index] = timer;
timerList [index] = runnable;
}
}

GTK:

if (GTK.GTK4) {
timerId = OS.g_timeout_add (milliseconds, timerProc, index);
} else {
timerId = GDK.gdk_threads_add_timeout (milliseconds, timerProc, index);
}
if (timerId != 0) {
timerIds [index] = timerId;
timerList [index] = runnable;
}
}

@github-actions
Copy link
Contributor

github-actions bot commented Nov 22, 2025

Test Results

  172 files  + 3    172 suites  +3   23m 56s ⏱️ - 3m 42s
4 679 tests +56  4 656 ✅ +73  23 💤 +4  0 ❌  - 6 
  466 runs  +38    461 ✅ +36   5 💤 +2  0 ❌ ±0 

Results for commit 74c1657. ± Comparison against base commit 35ce202.

This pull request removes 1 and adds 57 tests. Note that renamed tests count towards both.
org.eclipse.swt.tests.gtk.snippets.Bug336238_ShellSetBoundFailTest ‑ testSetBounds
AllWin32Tests ImageWin32Tests ‑ testDisposeDrawnImageBeforeRequestingTargetForOtherZoom
AllWin32Tests ImageWin32Tests ‑ testDrawImageAtDifferentZooms(boolean)[1] true
AllWin32Tests ImageWin32Tests ‑ testDrawImageAtDifferentZooms(boolean)[2] false
AllWin32Tests ImageWin32Tests ‑ testImageDataForDifferentFractionalZoomsShouldBeDifferent
AllWin32Tests ImageWin32Tests ‑ testImageShouldHaveDimesionAsPerZoomLevel
AllWin32Tests ImageWin32Tests ‑ testRetrieveImageDataAtDifferentZooms(boolean)[1] true
AllWin32Tests ImageWin32Tests ‑ testRetrieveImageDataAtDifferentZooms(boolean)[2] false
AllWin32Tests ImageWin32Tests ‑ test_getImageData_fromCopiedImage
AllWin32Tests ImageWin32Tests ‑ test_getImageData_fromImageForImageDataFromImage
AllWin32Tests TestTreeColumn ‑ test_ColumnOrder
…
This pull request skips 1 test.
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell ‑ test_activateEventSend

♻️ This comment has been updated with latest results.

At the moment the code silently fails on calling timerExec if there
are no handles left or it fails for other reasons.

Relates to eclipse-platform#2806
where we can see that we are running out of handles, but the timerExec
does not report a failure.

On Windows timer handles are related to user objects and are relatively
limited (10,000). For Linux and macOS the timers seem only to fail in
out of memory situations.
@jonahgraham jonahgraham marked this pull request as ready for review January 20, 2026 18:55
@jonahgraham
Copy link
Contributor Author

This is a draft for now because it needs consideration for other platforms and whether after 25 years there is a reason that this case was allowed to fail silently on Windows.

On macOS there is a pointless null check in the same place because an NPE would have already been raised. On GTK I need to investigate more because the functions are not documented as being able to fail.

My latest commit adds throwing no more handles on macos and gtk if the timer creation routines return 0/null so they also don't silently fail anymore.

I plan to submit this soon if there are no objections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant