Skip to content

Commit

Permalink
Merge from internal (#204)
Browse files Browse the repository at this point in the history
* Initial import of the Firebase Unity SDK  - 434873250 Update Firebase.Editor.dll to search for a "python" execu... by jsimantov <jsimantov@google.com>
  - 433819934 Update Unity FIS GetInstance and Auth GetAuth to always c... by Googler <noreply@google.com>
  - 427297110 Update the version number and guids for 8.8.1 by amaurice <amaurice@google.com>
  - 424921630 Fix TimeSpan being used incorrectly in RC Unity by amaurice <amaurice@google.com>
  - 424476677 Update the Unity version for M110 release (8.8.0) by amaurice <amaurice@google.com>
  - 424457207 Update Crashlytics Android SDK version for Firebase Unity... by Googler <noreply@google.com>
  - 424440457 Import firebase/firebase-cpp-sdk from GitHub. by amaurice <amaurice@google.com>
  - 423184695 Roll-up EDM4U version for Firebase SDK by chkuang <chkuang@google.com>
  - 421668891 Add script to copy unity github produced release artifact... by cynthiajiang <cynthiajiang@google.com>

PiperOrigin-RevId: 434873250

* Merge remote-tracking branch 'origin/master' into ghm

Co-authored-by: Googler <noreply@google.com>
Co-authored-by: Cynthia Jiang <cynthiajiang@google.com>
  • Loading branch information
3 people authored Mar 18, 2022
1 parent ee7e45d commit fcd3989
Show file tree
Hide file tree
Showing 10 changed files with 703 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/src/cpp_instance_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include <unordered_map>

#include "app/src/assert.h"
#include "app/src/log.h"
#include "app/src/include/firebase/internal/mutex.h"
#include "app/src/log.h"

namespace firebase {

Expand Down
18 changes: 17 additions & 1 deletion auth/src/swig/auth.i
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,19 @@ static CppInstanceManager<Auth> g_auth_instances;
return instance;
}

%csmethodmodifiers LogHeartbeatInternal(App* app) "internal";
static void LogHeartbeatInternal(App* app) {
// Call the internal getter in order to trigger usage logging.
::firebase::MutexLock lock(
::firebase::auth::g_auth_instances.mutex());
firebase::auth::Auth* instance = firebase::auth::Auth::GetAuth(app);
// Future-proof against the possibility of the instance having no other
// references by incrementing and decrementing the reference counter so that
// memory can be freed if the reference count reaches zero.
::firebase::auth::g_auth_instances.AddReference(instance);
::firebase::auth::g_auth_instances.ReleaseReference(instance);
}

// Release and decrement the reference count to a C++ instance
%csmethodmodifiers ReleaseReferenceInternal(firebase::auth::Auth* instance) "internal";
static void ReleaseReferenceInternal(firebase::auth::Auth* instance) {
Expand Down Expand Up @@ -522,7 +535,10 @@ static CppInstanceManager<Auth> g_auth_instances;
lock (appCPtrToAuth) {
System.IntPtr appCPtr = FirebaseApp.getCPtr(app).Handle;
auth = ProxyFromAppCPtr(appCPtr);
if (auth != null) return auth;
if (auth != null) {
LogHeartbeatInternal(app);
return auth;
}
InitResult init_result;
FirebaseApp.TranslateDllNotFoundException(() => {
auth = GetAuthInternal(app, out init_result);
Expand Down
2 changes: 1 addition & 1 deletion crashlytics/src/cpp/common/crashlytics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include "app/src/assert.h"
#include "app/src/cleanup_notifier.h"
#include "app/src/include/firebase/app.h"
#include "app/src/include/firebase/internal/mutex.h"
#include "app/src/include/firebase/version.h"
#include "app/src/log.h"
#include "app/src/include/firebase/internal/mutex.h"
#include "app/src/util.h"

#if defined(__ANDROID__)
Expand Down
24 changes: 23 additions & 1 deletion docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,31 @@ Support

Release Notes
-------------
### UNRELEASED
### 8.9.0
- Changes
- General (Editor, macOS): Support non-default "python" executable names,
common in newer macOS versions.

### 8.8.1
- Changes
- General (iOS): Fixed additional issues on iOS 15 caused by early
initialization of Firebase iOS SDK.

### 8.8.0
- Changes
- General (iOS): Another possible fix for an intermittent crash on iOS 15
caused by constructing C++ objects during Objective-C's `+load` method.
- Storage: Added a method to access the url of a storage instance.
- Crashlytics (Android): Updated internal Crashpad version to commit
`281ba7`. With this change, disabling tagged pointers is no longer
required, so the following can be removed from your manifest's
application tag: `android:allowNativeHeapPointerTagging=false`.
- Crashlytics (Android): Improved runtime efficiency of the
[`SetCustomKey` functions](/docs/crashlytics/customize-crash-reports?platform=unity#add-keys),
significantly reducing the number objects created and disk writes when
keys are updated frequently.
- Remote Config: Fixed an issue where the TimeSpan field of FetchDataAsync
was being used incorrectly.

### 8.7.0:
- Changes
Expand Down
46 changes: 42 additions & 4 deletions editor/app/src/PythonExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,53 @@ public string ScriptPath {
}
}

private const string PYTHON_INTERPRETER = "python";
private static readonly string[] PYTHON_INTERPRETERS = {
"python", "python3", "python3.8","python3.7", "python2.7", "python2"
};

private static string s_pythonInterpreter = null;

private static void FindPythonInterpreter() {
// Run each entry in PYTHON_INTERPRETERS in sequence until we get one
// that succeeds.
foreach (string interpreter in PYTHON_INTERPRETERS) {
try {
CommandLine.Result result = CommandLine.Run(interpreter, "--version");
if (result.exitCode == 0) {
s_pythonInterpreter = interpreter;
// Found one, finished!
return;
}
}
catch(Exception e) {
// This one failed, ignore and move on to the next one.
}
}
// Fall back to the first option in case none worked, so this doesn't
// keep retrying.
Debug.LogError(
"Could not find a working python interpreter. " +
"Please make sure one of the following is in your PATH: " +
String.Join(" ", PYTHON_INTERPRETERS));
s_pythonInterpreter = PYTHON_INTERPRETERS[0];
}

private static string PythonInterpreter {
get {
if (s_pythonInterpreter == null) {
FindPythonInterpreter();
}
return s_pythonInterpreter;
}
}

/// <summary>
/// Get the executable to run the script.
/// </summary>
public string Executable {
get {
return Application.platform == RuntimePlatform.WindowsEditor ?
ScriptPath : PYTHON_INTERPRETER;
ScriptPath : PythonInterpreter;
}
}

Expand All @@ -132,7 +170,7 @@ public string Executable {
/// <param name="arguments">List of arguments to pass to the script.</param>
/// <returns>List of arguments to pass to the Executable to run the script.</returns>
public IEnumerable<string> GetArguments(IEnumerable<string> arguments) {
if (Executable != PYTHON_INTERPRETER) return arguments;
if (Executable != PythonInterpreter) return arguments;
var argsWithScript = new List<string>();
argsWithScript.Add(String.Format("\"{0}\"", ScriptPath));
argsWithScript.AddRange(arguments);
Expand All @@ -155,7 +193,7 @@ public string GetCommand(IEnumerable<string> arguments) {
/// If execution fails on Windows 7/8, suggest potential remidies.
/// </summary>
private CommandLine.Result SuggestWorkaroundsOnFailure(CommandLine.Result result) {
if (result.exitCode != 0 && Executable != PYTHON_INTERPRETER) {
if (result.exitCode != 0 && Executable != PythonInterpreter) {
Debug.LogWarning(String.Format(DocRef.PythonScriptExecutionFailed, result.message,
Executable));
}
Expand Down
19 changes: 18 additions & 1 deletion installations/src/swig/installations.i
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ static CppInstanceManager<Installations> g_installations_instances;
return instance;
}

%csmethodmodifiers LogHeartbeatInternal(App* app) "internal";
static void LogHeartbeatInternal(App* app) {
// Call the internal getter in order to trigger usage logging.
::firebase::MutexLock lock(
::firebase::installations::g_installations_instances.mutex());
firebase::installations::Installations* instance =
firebase::installations::Installations::GetInstance(app);
// Future-proof against the possibility of the instance having no other
// references by incrementing and decrementing the reference counter so that
// memory can be freed if the reference count reaches zero.
::firebase::installations::g_installations_instances.AddReference(instance);
::firebase::installations::g_installations_instances.ReleaseReference(instance);
}

%csmethodmodifiers ReleaseReferenceInternal(firebase::installations::Installations* instance) "internal";
static void ReleaseReferenceInternal(
firebase::installations::Installations* instance) {
Expand Down Expand Up @@ -145,7 +159,10 @@ static CppInstanceManager<Installations> g_installations_instances;
lock (installationsByAppCPtr) {
System.IntPtr appCPtr = FirebaseApp.getCPtr(app).Handle;
installations = ProxyFromAppCPtr(appCPtr);
if (installations != null) return installations;
if (installations != null) {
LogHeartbeatInternal(app);
return installations;
}
FirebaseApp.TranslateDllNotFoundException(() => {
installations = GetInstallationsInternal(app);
});
Expand Down
Loading

0 comments on commit fcd3989

Please sign in to comment.