Skip to content

Commit 946199e

Browse files
v4.8.5
2 parents 3e12bd3 + 72fac1d commit 946199e

File tree

11 files changed

+62
-26
lines changed

11 files changed

+62
-26
lines changed

.travis.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
os: osx
2-
osx_image: xcode11.6
2+
osx_image: xcode11.3
33
before_cache:
44
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
55
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
@@ -33,12 +33,12 @@ before_install:
3333
- mkdir -p $TRAVIS_BUILD_DIR/build_artifacts
3434

3535
install:
36-
- brew cask uninstall java > /dev/null
37-
- brew cask install adoptopenjdk8 > /dev/null
36+
- brew uninstall --cask java > /dev/null
37+
- brew install --cask adoptopenjdk8 > /dev/null
3838
- brew install ninja > /dev/null
39-
- brew cask install https://raw.githubusercontent.com/caskroom/homebrew-cask/59a4123d2dc252d17db3fc9169889c96b23cda15/Casks/mono-mdk.rb > /dev/null
40-
- brew cask install android-sdk > /dev/null
41-
- brew cask install bugsnag/unity/$UNITY_VERSION > /dev/null
39+
- brew install --cask mono-mdk > /dev/null
40+
- brew install --cask android-sdk > /dev/null
41+
- brew install --cask bugsnag/unity/$UNITY_VERSION > /dev/null
4242
- export PATH="$PATH:/Library/Frameworks/Mono.framework/Versions/Current/Commands"
4343
- sdkmanager --list
4444
- yes | sdkmanager "platforms;android-27" > /dev/null
@@ -57,7 +57,6 @@ script:
5757
jobs:
5858
include:
5959
- stage: test
60-
osx_image: xcode11.3
6160
env:
6261
- UNITY_VERSION=unity-5-6-7f1
6362
- stage: test

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 4.8.5 (2021-03-03)
4+
5+
### Bug fixes
6+
7+
* Avoid JNI crash in leaveBreadcrumb by pushing local frame
8+
[#214](https://github.com/bugsnag/bugsnag-unity/pull/214)
9+
10+
* Respect autoNotify flag on Android
11+
[#207](https://github.com/bugsnag/bugsnag-unity/pull/207)
12+
313
## 4.8.4 (2020-10-05)
414

515
### Enhancements

bugsnag-android-unity/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ android {
2727
if (project.hasProperty("ABI_FILTERS")) {
2828
abiFilters project.ABI_FILTERS.split(",")
2929
} else {
30-
abiFilters 'arm64-v8a', 'armeabi-v7a', 'armeabi', 'x86', 'x86_64'
30+
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
3131
}
3232
}
3333
}

build.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var target = Argument("target", "Default");
55
var solution = File("./BugsnagUnity.sln");
66
var configuration = Argument("configuration", "Release");
77
var project = File("./src/BugsnagUnity/BugsnagUnity.csproj");
8-
var version = "4.8.4";
8+
var version = "4.8.5";
99

1010
Task("Restore-NuGet-Packages")
1111
.Does(() => NuGetRestore(solution));

src/BugsnagUnity/Configuration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ public abstract class AbstractConfiguration : IConfiguration
1212

1313
public AbstractConfiguration() {}
1414

15-
protected virtual void SetupDefaults(string apiKey)
15+
protected virtual void SetupDefaults(string apiKey, bool autoNotify)
1616
{
1717
ApiKey = apiKey;
1818
AppVersion = Application.version;
1919
AutoCaptureSessions = true;
20-
AutoNotify = true;
20+
AutoNotify = autoNotify;
2121
}
2222

2323
public virtual bool ReportUncaughtExceptionsAsHandled { get; set; } = true;

src/BugsnagUnity/Native/Android/Configuration.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ internal Configuration(string apiKey, bool autoNotify) : base()
2727
JavaObject.Call("setReleaseStage", "production");
2828
JavaObject.Call("setAppVersion", Application.version);
2929
NativeInterface = new NativeInterface(JavaObject);
30-
SetupDefaults(apiKey);
3130
_autoNotify = autoNotify;
31+
SetupDefaults(apiKey, _autoNotify);
3232
}
3333

34-
protected override void SetupDefaults(string apiKey)
34+
protected override void SetupDefaults(string apiKey, bool autoNotify)
3535
{
36-
base.SetupDefaults(apiKey);
36+
base.SetupDefaults(apiKey, autoNotify);
3737
ReleaseStage = "production";
3838
Endpoint = new Uri(DefaultEndpoint);
3939
SessionEndpoint = new Uri(DefaultSessionEndpoint);

src/BugsnagUnity/Native/Android/NativeInterface.cs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,31 @@ public NativeInterface(AndroidJavaObject config)
140140
}
141141
}
142142

143+
/**
144+
* Pushes a local JNI frame with 128 capacity. This avoids the reference table
145+
* being exceeded, which can happen on some lower-end Android devices in extreme conditions
146+
* (e.g. Nexus 7 running Android 6). This is likely due to AndroidJavaObject
147+
* not deleting local references immediately.
148+
*
149+
* If this call is unsuccessful it indicates the device is low on memory so the caller should no-op.
150+
* https://docs.unity3d.com/ScriptReference/AndroidJNI.PopLocalFrame.html
151+
*/
152+
private bool PushLocalFrame() {
153+
if (AndroidJNI.PushLocalFrame(128) != 0) {
154+
AndroidJNI.ExceptionClear(); // clear pending OutOfMemoryError.
155+
return false;
156+
}
157+
return true;
158+
}
159+
160+
/**
161+
* Pops the local JNI frame, freeing any references in the table.
162+
* https://docs.unity3d.com/ScriptReference/AndroidJNI.PopLocalFrame.html
163+
*/
164+
private void PopLocalFrame() {
165+
AndroidJNI.PopLocalFrame(System.IntPtr.Zero);
166+
}
167+
143168
public string GetAppVersion() {
144169
return CallNativeStringMethod("getAppVersion", "()Ljava/lang/String;", new object[]{});
145170
}
@@ -287,10 +312,13 @@ public void LeaveBreadcrumb(string name, string type, IDictionary<string, string
287312
if (!isAttached) {
288313
AndroidJNI.AttachCurrentThread();
289314
}
290-
using (AndroidJavaObject map = BuildJavaMapDisposable(metadata))
291-
{
292-
CallNativeVoidMethod("leaveBreadcrumb", "(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)V",
293-
new object[]{name, type, map});
315+
if (PushLocalFrame()) {
316+
using (AndroidJavaObject map = BuildJavaMapDisposable(metadata))
317+
{
318+
CallNativeVoidMethod("leaveBreadcrumb", "(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)V",
319+
new object[]{name, type, map});
320+
}
321+
PopLocalFrame();
294322
}
295323
if (!isAttached) {
296324
AndroidJNI.DetachCurrentThread();

src/BugsnagUnity/Native/Cocoa/Configuration.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ class Configuration : AbstractConfiguration
1717
internal Configuration(string apiKey, bool autoNotify) : base()
1818
{
1919
NativeConfiguration = NativeCode.bugsnag_createConfiguration(apiKey);
20-
SetupDefaults(apiKey);
21-
NativeCode.bugsnag_setAutoNotify(NativeConfiguration, autoNotify);
2220
_autoNotify = autoNotify;
21+
SetupDefaults(apiKey, autoNotify);
22+
NativeCode.bugsnag_setAutoNotify(NativeConfiguration, autoNotify);
2323
}
2424

25-
protected override void SetupDefaults(string apiKey)
25+
protected override void SetupDefaults(string apiKey, bool autoNotify)
2626
{
27-
base.SetupDefaults(apiKey);
27+
base.SetupDefaults(apiKey, autoNotify);
2828
ReleaseStage = "production";
2929
Endpoint = new Uri(DefaultEndpoint);
3030
}

src/BugsnagUnity/Native/Fallback/Configuration.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ namespace BugsnagUnity
77
class Configuration : AbstractConfiguration
88
{
99
internal Configuration(string apiKey, bool autoNotify) : base() {
10-
SetupDefaults(apiKey);
11-
AutoNotify = autoNotify;
10+
SetupDefaults(apiKey, autoNotify);
1211
}
1312
}
1413
}

tests/BugsnagUnity.Tests/ConfigurationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace BugsnagUnity.Payload.Tests
88
class TestConfig : AbstractConfiguration
99
{
1010
internal TestConfig(string apiKey) : base() {
11-
SetupDefaults(apiKey);
11+
SetupDefaults(apiKey, true);
1212
}
1313
}
1414

0 commit comments

Comments
 (0)