Skip to content

Commit

Permalink
fix: AppRegistry not callable from Native in bridgeless (#46480)
Browse files Browse the repository at this point in the history
Summary:
AppRegistry was not treated as a Callable Module in bridgeless mode. This is breaking headless tasks on Android.

Fixes:

 - #46050

## Changelog:

[ANDROID] [FIXED] - Made AppRegistry callable from Native code in Bridgeless (fixes headless tasks)

Pull Request resolved: #46480

Test Plan: Used repro from linked issue

Reviewed By: javache

Differential Revision: D62637486

Pulled By: cortinico

fbshipit-source-id: 756527003ac6d712e76c02c188e280d15c010068
  • Loading branch information
robik authored and facebook-github-bot committed Sep 13, 2024
1 parent b98b9f1 commit f3fee67
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/react-native/Libraries/ReactNative/AppRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {RootTag} from '../Types/RootTagTypes';
import type {IPerformanceLogger} from '../Utilities/createPerformanceLogger';
import type {DisplayModeType} from './DisplayMode';

import BatchedBridge from '../BatchedBridge/BatchedBridge';
import registerCallableModule from '../Core/registerCallableModule';
import BugReporting from '../BugReporting/BugReporting';
import createPerformanceLogger from '../Utilities/createPerformanceLogger';
import infoLog from '../Utilities/infoLog';
Expand Down Expand Up @@ -363,8 +363,8 @@ global.RN$SurfaceRegistry = {

if (global.RN$Bridgeless === true) {
console.log('Bridgeless mode is enabled');
} else {
BatchedBridge.registerCallableModule('AppRegistry', AppRegistry);
}

registerCallableModule('AppRegistry', AppRegistry);

module.exports = AppRegistry;
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,11 @@ public void run() {
@Override
public void onDestroy() {
super.onDestroy();
ReactContext reactContext = getReactContext();

if (getReactNativeHost().hasInstance()) {
ReactInstanceManager reactInstanceManager = getReactNativeHost().getReactInstanceManager();
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext != null) {
HeadlessJsTaskContext headlessJsTaskContext =
HeadlessJsTaskContext.getInstance(reactContext);
headlessJsTaskContext.removeTaskEventListener(this);
}
if (reactContext != null) {
HeadlessJsTaskContext headlessJsTaskContext = HeadlessJsTaskContext.getInstance(reactContext);
headlessJsTaskContext.removeTaskEventListener(this);
}
if (sWakeLock != null) {
sWakeLock.release();
Expand Down

0 comments on commit f3fee67

Please sign in to comment.