Closed Bug 758405 Opened 13 years ago Closed 13 years ago

Robocop: FennecNativeElement.click/getText/isDisplayed can hang indefinitely

Categories

(Testing :: General, defect)

x86
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla15

People

(Reporter: gbrown, Assigned: gbrown)

References

Details

Attachments

(1 file)

Intense testing with special logging shows that FennecNativeElement.click can hang indefinitely. (It happens rarely, but perhaps one time in a 500 clicks.) It appears that SynchronousQueue.offer may be called before SynchronousQueue.take, and in this case, take() never unblocks.
SynchronousQueue.offer(x) fails if the other thread has not called take() yet. It looks like SynchronousQueue.put(x) will do the job -- wait for the take if necessary.
FennecNativeElement.getText and FennecNativeElement.isDisplayed have the same flaw (but I have never observed it in these functions).
Summary: Robocop: FennecNativeElement.click can hang indefinitely → Robocop: FennecNativeElement.click/getText/isDisplayed can hang indefinitely
There are basically 2 changes here, each applied to the 3 functions that use SynchronousQueue for synchronization between the UI thread and the calling thread: 1. Use put() instead of offer(). If the calling thread is not yet waiting on take() or poll(), the put() will still succeed and the subsequent call to take() or poll() will unblock immediately; if the calling thread is waiting on take() or poll(), the put() will cause the calling thread to unblock. 2. Use poll(MAX_TIME_MS) instead of take() so that if something goes wrong on the UI thread and put() is not called, the caller unblocks after MAX_TIME_MS rather than hanging indefinitely. MAX_TIME_MS=60000 is chosen somewhat arbitrarily. I expect the poll to succeed in less than 1000 ms in almost all circumstances.
Attachment #627025 - Flags: review?(jmaher)
Comment on attachment 627025 [details] [diff] [review] fix synchronization problems in FennecNativeElement Review of attachment 627025 [details] [diff] [review]: ----------------------------------------------------------------- I like this idea in general. It will be interesting to see which tests fall hit this most often.
Attachment #627025 - Flags: review?(jmaher) → review+
Keywords: checkin-needed
Blocks: 756817
Flags: in-testsuite-
Keywords: checkin-needed
Target Milestone: --- → mozilla15
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: