[js/rn] Fix some bugs (#20242)

### Description
<!-- Describe your changes. -->
- Fix `logSeverityLevel`
- Correct get RCTCxxBridge, old method for some cases will got wrong
bridge


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

---------

Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com>
This commit is contained in:
Hans 2024-05-16 01:32:08 +08:00 committed by GitHub
parent 87ed1e3e3f
commit 2a17958b34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View file

@ -7,6 +7,7 @@ import ai.onnxruntime.OnnxTensor;
import ai.onnxruntime.OnnxValue;
import ai.onnxruntime.OrtEnvironment;
import ai.onnxruntime.OrtException;
import ai.onnxruntime.OrtLoggingLevel;
import ai.onnxruntime.OrtSession;
import ai.onnxruntime.OrtSession.Result;
import ai.onnxruntime.OrtSession.RunOptions;
@ -421,7 +422,7 @@ public class OnnxruntimeModule extends ReactContextBaseJavaModule implements Lif
if (options.hasKey("logSeverityLevel")) {
int logSeverityLevel = options.getInt("logSeverityLevel");
sessionOptions.setSessionLogVerbosityLevel(logSeverityLevel);
sessionOptions.setSessionLogLevel(OrtLoggingLevel.mapFromInt(logSeverityLevel));
}
return sessionOptions;
@ -432,7 +433,7 @@ public class OnnxruntimeModule extends ReactContextBaseJavaModule implements Lif
if (options.hasKey("logSeverityLevel")) {
int logSeverityLevel = options.getInt("logSeverityLevel");
runOptions.setLogVerbosityLevel(logSeverityLevel);
runOptions.setLogLevel(OrtLoggingLevel.mapFromInt(logSeverityLevel));
}
if (options.hasKey("tag")) {

View file

@ -5,11 +5,16 @@
@implementation OnnxruntimeJSIHelper
@synthesize bridge = _bridge;
RCT_EXPORT_MODULE()
- (void)setBridge:(RCTBridge *)bridge {
_bridge = bridge;
}
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
RCTBridge *bridge = [RCTBridge currentBridge];
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)_bridge;
if (cxxBridge == nil) {
return @false;
}