-
Notifications
You must be signed in to change notification settings - Fork 69
[ffigen] Fix flaky tests #1471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ffigen] Fix flaky tests #1471
Conversation
PR HealthChangelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR). License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
Package publish validation ✔️
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
Can't repro the global test failures locally. Hopefully this fix works? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! We might want to change stuff so objects somehow stay in scope until the end of the block.
@@ -97,6 +92,10 @@ void main() { | |||
expect(objectRetainCount(obj2raw), 3); | |||
expect(objectRetainCount(obj3raw), 2); | |||
|
|||
expect(obj1, isNotNull); // Force obj1 to stay in scope. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would not be needed if the objects are Finalizable
, but objects being Finalizable
make them non-sharable.
So maybe we need the "StayAlive
" marker interface @dcharkes!
In JNIgen I don't have a direct .pointer
getter, instead users have to write .reference.pointer
maybe that fixes the issue? I wonder if that works as .reference
is used in the scope and is Finalizable
but Pointer
is not Finalizable
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not worried about it. This is only an issue in these tests, where I'm explicitly testing the GC behavior. I don't think this will matter to users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am worried about it lol! We had this GC problem in package:jni
that happened in user code randomly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. How did it manifest for users? I haven't been able to think of a situation where it would matter, other than tests like this.
Fixes #1435