-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[webview_flutter_android] [camera_android_camerax] Updates internal Java InstanceManager to only stop finalization callbacks when stopped #3571
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
Merged
auto-submit
merged 11 commits into
flutter:main
from
bparrishMines:instance_manager_update
Apr 14, 2023
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1fe8a4e
update webview_flutter instance mangaer
bparrishMines 412036c
camerax side of change
bparrishMines ee44f2f
version bump
bparrishMines f73f110
version bump camerax
bparrishMines c5fe12e
stopped
bparrishMines 10899d0
Merge branch 'main' of github.com:flutter/packages into instance_mana…
bparrishMines c42d4da
add test
bparrishMines cb0c128
remove tests
bparrishMines 7379b40
Merge branch 'main' of github.com:flutter/packages into instance_mana…
bparrishMines 2ec0a60
add integration test
bparrishMines c559338
make constant private again
bparrishMines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add integration test
- Loading branch information
commit 2ec0a601fc13872966e2efda58f2b2a1d07f859a
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...droid/app/src/androidTest/java/io/flutter/plugins/cameraxexample/InstanceManagerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package io.flutter.plugins.cameraexample; | ||
|
|
||
| import static io.flutter.plugins.camerax.InstanceManager.CLEAR_FINALIZED_WEAK_REFERENCES_INTERVAL; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertNull; | ||
|
|
||
| import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
| import io.flutter.plugins.camerax.InstanceManager; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
|
|
||
| @RunWith(AndroidJUnit4.class) | ||
| public class InstanceManagerTest { | ||
| @Test | ||
| public void managerDoesNotTriggerFinalizationListenerWhenStopped() throws InterruptedException { | ||
| final boolean[] callbackTriggered = {false}; | ||
| final InstanceManager instanceManager = | ||
| InstanceManager.create(identifier -> callbackTriggered[0] = true); | ||
| instanceManager.stopFinalizationListener(); | ||
|
|
||
| Object object = new Object(); | ||
| instanceManager.addDartCreatedInstance(object, 0); | ||
|
|
||
| assertEquals(object, instanceManager.remove(0)); | ||
|
|
||
| // To allow for object to be garbage collected. | ||
| //noinspection UnusedAssignment | ||
| object = null; | ||
|
|
||
| Runtime.getRuntime().gc(); | ||
|
|
||
| Thread.sleep(CLEAR_FINALIZED_WEAK_REFERENCES_INTERVAL); | ||
|
|
||
| assertNull(instanceManager.getInstance(0)); | ||
| assertFalse(callbackTriggered[0]); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...pp/src/androidTest/java/io/flutter/plugins/webviewflutterexample/InstanceManagerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package io.flutter.plugins.webviewflutterexample; | ||
|
|
||
| import static io.flutter.plugins.webviewflutter.InstanceManager.CLEAR_FINALIZED_WEAK_REFERENCES_INTERVAL; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertNull; | ||
|
|
||
| import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
| import io.flutter.plugins.webviewflutter.InstanceManager; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
|
|
||
| @RunWith(AndroidJUnit4.class) | ||
| public class InstanceManagerTest { | ||
| @Test | ||
| public void managerDoesNotTriggerFinalizationListenerWhenStopped() throws InterruptedException { | ||
| final boolean[] callbackTriggered = {false}; | ||
| final InstanceManager instanceManager = | ||
| InstanceManager.create(identifier -> callbackTriggered[0] = true); | ||
| instanceManager.stopFinalizationListener(); | ||
|
|
||
| Object object = new Object(); | ||
| instanceManager.addDartCreatedInstance(object, 0); | ||
|
|
||
| assertEquals(object, instanceManager.remove(0)); | ||
|
|
||
| // To allow for object to be garbage collected. | ||
| //noinspection UnusedAssignment | ||
| object = null; | ||
|
|
||
| Runtime.getRuntime().gc(); | ||
|
|
||
| Thread.sleep(CLEAR_FINALIZED_WEAK_REFERENCES_INTERVAL); | ||
|
|
||
| assertNull(instanceManager.getInstance(0)); | ||
| assertFalse(callbackTriggered[0]); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.