the title basically says it all, I am trying to run a very basic Unity game which captures 2 emotions using Affectiva's emotion SDK for Unity. The game is buttery smooth on even low end Android devices but its not so smooth on iOS devices (currently tested on iPhone 6 - iOS 10, 6s - iOS 11, 7). I have attached the Detector and Camera Input script to the Main Camera in my game scene, sample rate is set to 8, Target Width is 320 and Target Height is 240. But no matter what the game does not run smoothly. As soon as I disable these 2 scripts the game starts running smoothly on iOS. Any suggestions for improving the game performance?
Asked
Active
Viewed 104 times
1 Answers
0
There is an unreleased change that makes performance improvements. Can you please try this change and see if it helps:
From 876c21d95eb84759742a4640f9fd30f4c6aa3518 Mon Sep 17 00:00:00 2001
From: Forest Handford <forest.handford@affectiva.com>
Date: Mon, 28 Aug 2017 13:21:17 +0200
Subject: [PATCH] SDK-1316: Sofia's performance changes
---
.../Assets/Affdex/Plugins/Scripts/AndroidNativePlatform.cs | 2 +-
UnityPlugin/Assets/Affdex/Plugins/Scripts/Detector.cs | 1 +
UnityPlugin/Assets/Affdex/Plugins/Scripts/NativePlatform.cs | 9 ++++++++-
UnityPlugin/Assets/Affdex/Plugins/Scripts/OSXNativePlatform.cs | 2 +-
.../Assets/Affdex/Plugins/Scripts/WindowsNativePlatform.cs | 2 +-
UnityPlugin/Assets/Affdex/Plugins/Scripts/iOSNativePlatform.cs | 2 +-
6 files changed, 13 insertions(+), 5 deletions(-)
mode change 100644 => 100755 UnityPlugin/Assets/Affdex/Plugins/Scripts/AndroidNativePlatform.cs
mode change 100644 => 100755 UnityPlugin/Assets/Affdex/Plugins/Scripts/Detector.cs
mode change 100644 => 100755 UnityPlugin/Assets/Affdex/Plugins/Scripts/NativePlatform.cs
mode change 100644 => 100755 UnityPlugin/Assets/Affdex/Plugins/Scripts/OSXNativePlatform.cs
mode change 100644 => 100755 UnityPlugin/Assets/Affdex/Plugins/Scripts/WindowsNativePlatform.cs
mode change 100644 => 100755 UnityPlugin/Assets/Affdex/Plugins/Scripts/iOSNativePlatform.cs
diff --git a/UnityPlugin/Assets/Affdex/Plugins/Scripts/AndroidNativePlatform.cs b/UnityPlugin/Assets/Affdex/Plugins/Scripts/AndroidNativePlatform.cs
old mode 100644
new mode 100755
index 07e9af2..885dfce
--- a/UnityPlugin/Assets/Affdex/Plugins/Scripts/AndroidNativePlatform.cs
+++ b/UnityPlugin/Assets/Affdex/Plugins/Scripts/AndroidNativePlatform.cs
@@ -58,7 +58,7 @@ namespace Affdex
public override IEnumerator Initialize (Detector detector, int discrete)
{
- AndroidNativePlatform.detector = detector;
+ this.detector = detector;
// assemble the destination path where the data files will go
affdexDataDir = Path.Combine(Application.persistentDataPath, "affdex-data");
diff --git a/UnityPlugin/Assets/Affdex/Plugins/Scripts/Detector.cs b/UnityPlugin/Assets/Affdex/Plugins/Scripts/Detector.cs
old mode 100644
new mode 100755
index f5f1645..f5b6a41
--- a/UnityPlugin/Assets/Affdex/Plugins/Scripts/Detector.cs
+++ b/UnityPlugin/Assets/Affdex/Plugins/Scripts/Detector.cs
@@ -53,6 +53,7 @@ namespace Affdex
set
{
listener = value;
+ Debug.Log("Detector listener set");
}
}
diff --git a/UnityPlugin/Assets/Affdex/Plugins/Scripts/NativePlatform.cs b/UnityPlugin/Assets/Affdex/Plugins/Scripts/NativePlatform.cs
old mode 100644
new mode 100755
index 610402f..0484f1c
--- a/UnityPlugin/Assets/Affdex/Plugins/Scripts/NativePlatform.cs
+++ b/UnityPlugin/Assets/Affdex/Plugins/Scripts/NativePlatform.cs
@@ -34,9 +34,16 @@ namespace Affdex
}
}
+ /// internal static class DetectorHelper: Detector
+ /// {
+ ///code to be inserted here when I figure it out, something about a public void
+ ///
+
+ /// }
+
public abstract class NativePlatform : MonoBehaviour
{
- protected static Detector detector;
+ protected Detector detector;
//Free these when platform closes!
protected GCHandle h1, h2, h3; //handles to unmanaged function pointer callbacks
diff --git a/UnityPlugin/Assets/Affdex/Plugins/Scripts/OSXNativePlatform.cs b/UnityPlugin/Assets/Affdex/Plugins/Scripts/OSXNativePlatform.cs
old mode 100644
new mode 100755
index 299dbd1..5e72c44
--- a/UnityPlugin/Assets/Affdex/Plugins/Scripts/OSXNativePlatform.cs
+++ b/UnityPlugin/Assets/Affdex/Plugins/Scripts/OSXNativePlatform.cs
@@ -56,7 +56,7 @@ namespace Affdex
public override IEnumerator Initialize(Detector detector, int discrete)
{
- OSXNativePlatform.detector = detector;
+ this.detector = detector;
String adP = Application.streamingAssetsPath;
String affdexDataPath = Path.Combine(adP, "affdex-data-osx");
int status = 0;
diff --git a/UnityPlugin/Assets/Affdex/Plugins/Scripts/WindowsNativePlatform.cs b/UnityPlugin/Assets/Affdex/Plugins/Scripts/WindowsNativePlatform.cs
old mode 100644
new mode 100755
index 47681df..f91f319
--- a/UnityPlugin/Assets/Affdex/Plugins/Scripts/WindowsNativePlatform.cs
+++ b/UnityPlugin/Assets/Affdex/Plugins/Scripts/WindowsNativePlatform.cs
@@ -57,7 +57,7 @@ namespace Affdex
public override IEnumerator Initialize(Detector detector, int discrete)
{
- WindowsNativePlatform.detector = detector;
+ this.detector = detector;
//load our lib!
string affdexDataPath = Application.streamingAssetsPath + "/affdex-data-3";
diff --git a/UnityPlugin/Assets/Affdex/Plugins/Scripts/iOSNativePlatform.cs b/UnityPlugin/Assets/Affdex/Plugins/Scripts/iOSNativePlatform.cs
old mode 100644
new mode 100755
index 8a61512..d37a631
--- a/UnityPlugin/Assets/Affdex/Plugins/Scripts/iOSNativePlatform.cs
+++ b/UnityPlugin/Assets/Affdex/Plugins/Scripts/iOSNativePlatform.cs
@@ -88,7 +88,7 @@ namespace Affdex
public override IEnumerator Initialize(Detector detector, int discrete)
{
- iOSNativePlatform.detector = detector;
+ this.detector = detector;
String adP = Application.streamingAssetsPath;
String affdexDataPath = Path.Combine(adP, "affdex-data-osx");
--
2.7.4.1.g5468f9e

Forest J. Handford
- 383
- 5
- 20
-
1Hi Forest, this has improved my game a bit although the game is still not nearly as smooth on iOS devices as it is on Android devices. Thanks for the reply though, are there any more suggestions that you can provide me? Also, can you be kind enough to tell me what is the technique called that would make these changes simultaneously to all my files together, there must be some way in the format that you have provided. Just a little nudge to what im looking for would be great. Thanks :) – m.umar Sep 27 '17 at 20:38
-
As salaam alaikum Muhammad, here is an SO article that talks about applying diffs: https://stackoverflow.com/questions/12320863/how-do-you-take-a-git-diff-file-and-apply-it-to-a-local-branch-that-is-a-copy-o The main way to reduce CPU usage of the Affectiva plugin is by reducing the frame rate and resolution. You might try 5 instead of 8, but I wouldn't go lower. I'll ask my co-workers if they can think of anything else. Thanks for the update. We need to get this patch out soon! – Forest J. Handford Sep 29 '17 at 13:42
-
1Walaikumasslam. I have already tried reducing the frame rate and the resolution doesn't make a lot of difference. I'll try to keep optimising the game further wherever I can. Thanks for the tips on the SDK and the link to applying diffs, their is always something new to learn :) – m.umar Sep 30 '17 at 22:42
-
Great, I believe one of my colleagues is also going to reach out to you to see if he can reproduce the issue you've found. If you can give him sample code it will be super helpful. شکریہ – Forest J. Handford Oct 02 '17 at 14:08